3

Using curl command, how to transfer a file from one location to other via HTTP request?

3 Answers3

1

Generally, you use cURL to download a file that is available on a web server to your local machine.

For example, if I wanted to download the cURL source:

curl http://curl.haxx.se/download/curl-7.28.1.tar.gz -o curl-7.28.1.tar.gz

wget is another popular tool for doing this, and you don't need to specify an output file with -o:

wget http://curl.haxx.se/download/curl-7.28.1.tar.gz
Gustav Bertram
  • 247
  • 4
  • 12
0

Curl is a command line utility for transferring data from or to a server designed to work without user interaction. With curl, you can download or upload data using one of the supported protocols including HTTP, HTTPS, SCP, SFTP, and FTP.

Source : https://linuxize.com/post/curl-command-examples/

This is a curl request I use to send a .wav file (audio clip) to a remote server using Git Bash.

H is the header where I send an API SECRET which requires by my backend service. F is the audio file I send with the request.

curl \
    -H 'API_SECRET: eyJhiJIUzI19NiJ9._AKdgMbK-_en8' \
    -F "file=@myaudiofile.wav" \
    https://someurl/api/

Note :

  1. Replace "someurl" with the api url to your backend service.
  2. There has to be a file by the given name (in my case myaudiofile.wav) in the directory from where you execute the curl command.

I hope this helps.

0

The simple form is:

curl <url to retrieve>
John
  • 1,433