How to send binary file URL in the curl command instead passing local path
What's happening here is that you're misusing the @
flag for the --data-binary
option. The man page
for curl
describes its use quite clearly
If you start the data with the letter
@
, the rest should be a file name to read the data from, or-
if you wantcurl
to read the data from stdin.
What you wrote instructed curl
to use the file called app-debug.apk
from the subdirectory example.com
:
curl ... --data-binary @example.com/app-debug.apk
It then told you that it couldn't find that file, but then proceeded to complete the rest of the command, resulting in an empty POST
:
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.
Nowhere does it say that @
can be used to reference a URI, so what you need to do is to get the artifact yourself and then POST
it to your server. Something like either of these suggestions could work
Download the POST content and then upload it
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
Stream the POST content and upload it
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 @-
Related videos on Youtube
harshal chandile
Updated on September 18, 2022Comments
-
harshal chandile over 1 year
I am trying to post a binary .apk file which is on s3 bucket to a POST API.
Local way which I know is:
curl -X POST https://xxx.example.com:443/api/storage/upload -H "Content-Type:application/octet-stream" --data-binary @file_name.file
But
I when I try the following, it is not working
curl -X POST https://xxx.example.com:443/api/storage/upload -H "Content-Type:application/octet-stream" --data-binary @example.com/app-debug.apk
I am getting below Error.
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.
-
Panki about 5 years'It's not working' ... what are we supposed to do with this information? What is not working? What error do you get?
-
roaima about 5 years... And what is it you're actually trying to do?
-
ctrl-alt-delor about 5 yearsIf you use the same account, then you can edit your own questions.
-
ilkkachu about 5 yearsIs that the exact command you ran and the exact error message? Or is that you masked the actual filename from the command, but not from the error message?
-