我正在尝试将 s3 存储桶上的二进制 .apk 文件发布到 POST API。
我知道的本地方式是:
curl -X POST https://xxx.example.com:443/api/storage/upload -H "Content-Type:application/octet-stream" --data-binary @file_name.file
Run Code Online (Sandbox Code Playgroud)
但
当我尝试以下操作时,它不起作用
curl -X POST https://xxx.example.com:443/api/storage/upload -H "Content-Type:application/octet-stream" --data-binary @example.com/app-debug.apk
Run Code Online (Sandbox Code Playgroud)
我低于错误。
Run Code Online (Sandbox Code Playgroud)Warning: Couldn't read data from file Warning: "https://s3-eu-west-1.amazonaws.com/files.greenhouseci.com/projects/6d Warning: 7f406a-2a65-4be0-83ee-75ca0afae7c9/builds/24f78eb5-819f-44d5-9c21-edce Warning: 4dc9f253/artefacts/app-debug.apk", this makes an empty POST.
这里发生的情况是您滥用了@
该--data-binary
选项的标志。for非常清楚地描述了它的man page
用法curl
如果您以字母 开头数据
@
,则其余部分应该是从中读取数据的文件名,或者-
如果您想从stdincurl
读取数据。
您编写的内容指示curl
使用从子目录调用的文件:app-debug.apk
example.com
Run Code Online (Sandbox Code Playgroud)curl ... --data-binary @example.com/app-debug.apk
然后它告诉您它找不到该文件,但随后继续完成命令的其余部分,导致空的POST
:
Run Code Online (Sandbox Code Playgroud)Warning: Couldn't read data from file Warning: "https://s3-eu-west-1.amazonaws.com/files.greenhouseci.com/projects/6d Warning: 7f406a-2a65-4be0-83ee-75ca0afae7c9/builds/24f78eb5-819f-44d5-9c21-edce Warning: 4dc9f253/artefacts/app-debug.apk", this makes an empty POST.
没有任何地方说@
可以用来引用 URI,因此您需要做的是自己获取工件,然后将POST
其发送到您的服务器。像这些建议中的任何一个都可以工作
下载POST内容然后上传
curl https://example.com/app-debug.apk >app-debug.apk
curl -X POST https://xxx.example.com:443/api/storage/upload -H "Content-Type:application/octet-stream" --data-binary @app-debug.apk
Run Code Online (Sandbox Code Playgroud)流式传输 POST 内容并上传
curl https://example.com/app-debug.apk |
curl -X POST https://xxx.example.com:443/api/storage/upload -H "Content-Type:application/octet-stream" --data-binary @-
Run Code Online (Sandbox Code Playgroud) 归档时间: |
|
查看次数: |
17537 次 |
最近记录: |