Copying Local Files with Curl

Copying local files with curl

You could say:

curl -o /path/to/destination file:///path/to/source/file 

This would copy /path/to/source/file to /path/to/destination.

Correct curl command for uploading local file to url

There's more than one way to "upload a file to a URL", so we cannot actually know unless you give us more details.

But what's clear is that that you lack either a -d or a -F option on your command line, and you should drop the -X POST.

Multi-part formpost

If you upload with a multipart, which is how most "uploads" to HTTP works, it could be something like this:

curl https://waapi.pepipost.com/api/v2/media/upload/ -H 'Authorization: Bearer myAuthorizationToken' -F "file=@C:\Users\Slomil\Desktop\UserGuide.pdf"

Note that this command line sets the upload part to get the name file, which you should change to the name you want.

"regular" POST

If you just want to send the binary file "raw" in a POST (which your setting of Content-Type might indicate you want), use --data-binary like this:

curl https://waapi.pepipost.com/api/v2/media/upload/ -H 'Authorization: Bearer myAuthorizationToken' -H 'Content-Type: document' --data-binary "@C:\Users\Slomil\Desktop\UserGuide.pdf"

(I copied the Content-Type from the question, although it looks unusual and odd.)

Copy all files from a directory to FTP with cURL

Since you are on Windows OS, you cannot use Find and curl commands mentioned here to upload your files to FTP.
To Upload files to FTP server using windows command prompt, you can follow the below steps:

  • Open Command Prompt.
  • Type Command -> ftp ftps.pmc.com
  • You will now be connected to ftp. It will say Connected to ftps.pmc.com.
  • You will be asked to enter username and password. Please enter it correctly.
  • First enter username, once that username available, you will be asked to enter password.
  • Password will not display anything on the screen while typing, you need to make sure that you do not press backspace or any other key while typing password as it will directly read the password from your keyboard inputs.
  • Once you are successfully connected to it, you need to move to your required directory on ftp server using cd command. e.g., cd test
  • Then, to copy files from your local machine you need to enter command -> lcd Users/a/Desktop/Test/
  • Then put command will be used to upload your files to the ftp server. put *.txt will upload all your text files to the current folder on ftp. mput will upload all files from Users/a/Desktop/Test/ local folder to the current folder on ftp one by one.
  • mput command can also be used to upload the whole folder.
  • Please note that command and files names used here in the command prompt will be case sensitive.

So the list of command will be

 1. ftp ftps.pmc.com 
2. ftpuser
3. ftppass
4. cd test
5. lcd Users/a/Desktop/Test/
6. put *.txt (OR mput)

Send request to cURL with post data sourced from a file

You're looking for the --data-binary argument:

curl -i -X POST host:port/post-file \
-H "Content-Type: text/xml" \
--data-binary "@path/to/file"

In the example above, -i prints out all the headers so that you can see what's going on, and -X POST makes it explicit that this is a post. Both of these can be safely omitted without changing the behaviour on the wire. The path to the file needs to be preceded by an @ symbol, so curl knows to read from a file.

Dockerfile: how to Download a file using curl and copy into the container

Based on your comments below, you may try this one:

FROM prismagraphql/prisma:1.34.8

RUN apk update && apk add build-base dumb-init curl

RUN curl -LJO https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh

RUN cp wait-for-it.sh /app/

RUN chmod +x /wait-for-it.sh

ENTRYPOINT ["/bin/sh","-c","/wait-for-it.sh mysql:3306 --timeout=0 -- /app/start.sh"]

Note: You need to use cp command as you want to copy the script from one location to another within your container's filesystem.

You can also confirm the presence of your script and other files/dirs in the /app folder by running the command:

$ docker run --rm --entrypoint ls waitforit -l /app/
total 36
drwxr-xr-x 1 root root 4096 Aug 29 2019 bin
drwxr-xr-x 2 root root 16384 Aug 29 2019 lib
-rwxr-xr-x 1 root root 462 Aug 29 2019 prerun_hook.sh
-rwxr-xr-x 1 root root 61 Aug 29 2019 start.sh
-rw-r--r-- 1 root root 5224 Apr 22 13:46 wait-for-it.sh


Related Topics



Leave a reply



Submit