如何使用powershell将文件上传到anonfiles
How to upload files to anonfiles with powershell
所以我对 powershell 有点陌生,想制作一个简单的脚本,将所选文件上传到 anonyfiles。我遇到的问题是上传到 api 我已经设法通过 cmd 上传了它,但现在我希望我可以通过 powershell 来完成。
我用来通过cmd上传文件的命令是:
curl -F "file=@C:\Eclips-Terminal\Websites.csv" https://api.anonfiles.com/upload
重述一下:
- 上传文件到 anonfiles (https://anonfiles.com/)
- 如果可能,将输出过滤为只有短 url.
网址:
- https://anonfiles.com/docs/api(API-详情)
- https://anonfiles.com(网站)
欢迎所有帮助。
在 powershell 中 curl
是 Invoke-WebRequest
的别名。
get-alias curl
CommandType Name Version Source
----------- ---- ------- ------
Alias curl -> Invoke-WebRequest
您仍然可以 运行 可以在 cmd 中 运行 的 powershell 中的任何可执行文件,只需指定可执行文件即可。
curl.exe -F "file=@C:\Eclips-Terminal\Websites.csv" https://api.anonfiles.com/upload?token=<YOUR API KEY>
您会注意到红色文本,这不是错误,而是 curl.exe 将其进度写入 stderr 流的方式,在 powershell 中以红色显示。我毫不怀疑有一个 switch/parameter 你可以在 curl.exe 上使用来忽略这个进度输出,但一个简单的方法是将 stderr 传递到 $null
.
curl.exe -F "file=@C:\Eclips-Terminal\Websites.csv" https://api.anonfiles.com/upload?token=<YOUR API KEY> 2>$null
最后,如果您将剩余的输出捕获到一个变量,那么您可以从中提取短 url。
$output = curl.exe -F "file=@C:\Eclips-Terminal\Websites.csv" https://api.anonfiles.com/upload?token=<YOUR API KEY> 2>$null
($output | ConvertFrom-Json).data.file.url.short
所以我对 powershell 有点陌生,想制作一个简单的脚本,将所选文件上传到 anonyfiles。我遇到的问题是上传到 api 我已经设法通过 cmd 上传了它,但现在我希望我可以通过 powershell 来完成。
我用来通过cmd上传文件的命令是:
curl -F "file=@C:\Eclips-Terminal\Websites.csv" https://api.anonfiles.com/upload
重述一下:
- 上传文件到 anonfiles (https://anonfiles.com/)
- 如果可能,将输出过滤为只有短 url.
网址:
- https://anonfiles.com/docs/api(API-详情)
- https://anonfiles.com(网站)
欢迎所有帮助。
在 powershell 中 curl
是 Invoke-WebRequest
的别名。
get-alias curl
CommandType Name Version Source
----------- ---- ------- ------
Alias curl -> Invoke-WebRequest
您仍然可以 运行 可以在 cmd 中 运行 的 powershell 中的任何可执行文件,只需指定可执行文件即可。
curl.exe -F "file=@C:\Eclips-Terminal\Websites.csv" https://api.anonfiles.com/upload?token=<YOUR API KEY>
您会注意到红色文本,这不是错误,而是 curl.exe 将其进度写入 stderr 流的方式,在 powershell 中以红色显示。我毫不怀疑有一个 switch/parameter 你可以在 curl.exe 上使用来忽略这个进度输出,但一个简单的方法是将 stderr 传递到 $null
.
curl.exe -F "file=@C:\Eclips-Terminal\Websites.csv" https://api.anonfiles.com/upload?token=<YOUR API KEY> 2>$null
最后,如果您将剩余的输出捕获到一个变量,那么您可以从中提取短 url。
$output = curl.exe -F "file=@C:\Eclips-Terminal\Websites.csv" https://api.anonfiles.com/upload?token=<YOUR API KEY> 2>$null
($output | ConvertFrom-Json).data.file.url.short