如何使用powershell将文件上传到anonfiles

时间:2021-01-05 10:56:18

标签: powershell file-upload upload

所以我对 powershell 有点陌生,想制作一个简单的脚本,将所选文件上传到 anonyfiles。我遇到的问题是上传到 api 我已经设法通过 cmd 上传它,但现在我希望我可以通过 powershell 做到这一点。

我用来通过cmd上传文件的命令是:

return AppBar(                                                                              
      elevation: 0.0,                                                                           
      centerTitle: true,                                                                       
      //automaticallyImplyLeading: false,                                                       
      titleSpacing: 0.0,                                                                        
      title: Row(                                                                               
        mainAxisAlignment: MainAxisAlignment.center,                                            
        children: [                                                                             
          SizedBox(                                                                             
            width: MediaQuery.of(context).size.width / 2,                                       
            child: Text(                                                                                         
                getTranslated(context, 'total_click:'),                                         
                textDirection: TextDirection.ltr,                                               
                textAlign: TextAlign.right),                                                     
          ),                                                                                     
          SizedBox(                                                                             
            width: MediaQuery.of(context).size.width / 2 - 100,                                       
            child: Text("$appbarcounter",                                                                                              
                textDirection: TextDirection.ltr,                                               
                textAlign: TextAlign.left),                                                      
          ),                                                                                     
        ],                                                                                      
      ),

重申一下:

网址:

欢迎所有帮助。

1 个答案:

答案 0 :(得分:0)

在 powershell 中,6curl 的别名。

Invoke-WebRequest

您仍然可以在powershell中运行任何可以在cmd中运行的可执行文件,只需指定可执行文件即可。

get-alias curl

CommandType     Name                                               Version    Source                   
-----------     ----                                               -------    ------                   
Alias           curl -> Invoke-WebRequest

您会注意到红色文本,这不是错误,而是 curl.exe 将其进度写入 stderr 流的方式,该流在 powershell 中显示为红色。我毫不怀疑,您可以在 curl.exe 上使用一个开关/参数来省略此进度输出,但一个简单的方法是将 stderr 用管道传输到 curl.exe -F "file=@C:\Eclips-Terminal\Websites.csv" https://api.anonfiles.com/upload?token=<YOUR API KEY>

$null

最后,如果您将剩余的输出捕获到一个变量中,那么您可以从中提取您的短网址。

curl.exe -F "file=@C:\Eclips-Terminal\Websites.csv" https://api.anonfiles.com/upload?token=<YOUR API KEY> 2>$null