How to upload a file in a url via curl?

I have an image in a URL like https://i.postimg.cc/GpDskmSG/sdssds.png and I want to send it over to be stored at nft.storage. Could I send it directly as a URL instead of a file from a path? I tried the below but it only stores the image URL.

curl -H "Authorization: Bearer eyJhbGciOiJIwetertyrtyUzI1NiIsInR5cCI6Ikp" -H "Content-Type: image/png" --data "https://i.postimg.cc/GpDskmSG/sdssds.png" --url "https://api.nft.storage/upload"

Iā€™m using windows curl

This command actually uploads the string https://i.postimg.cc/GpDskmSG/sdssds.png.

You first want to fetch your file then send it, like that :

curl https://i.postimg.cc/GpDskmSG/sdssds.png | curl -H "Authorization: Bearer eyJhbGciOiJIwetertyrtyUzI1NiIsInR5cCI6Ikp" -H "Content-Type: image/png" --data-binary "@-" --url "https://api.nft.storage/upload"

The first thing just download the file, then itā€™s | piped into the input of the second one, note the --data-binary @-, @ means ā€œRead content from a fileā€ rather than actually reading the string and - is the STD, here stdin (whats coming from pipe).

This require | to work correctly (work like on bash) so you should use mingw, or WSL2. :slight_smile:

Awesome! Thanks to you I managed to upload it.

And also, I supposed to do this programmatically using PHP, could it support the pipe symbol? OR should I just call the curl twice? First to download the file and second to upload to ipfs?