Updating a file on the repository with the contend of a file in the local machine

, ,

I am trying to update a file in my repo with the gitlab API. I have the following command:

    curl -v --request PUT --header "PRIVATE-TOKEN:$ACCESS_TOKEN" -F "branch=master" -F "author_email=email" -F "author_name=mea" -F "content=@path/to/local/file" -F "commit_message=testing the api" "https://repo/api/v4/projects/$PROJECT_ID/repository/files/db.sql"

If I change the content to any string it works, but I want the content to be the content of my local file, How can I achieve this?

I guess this is a curl thing, but this worked for me:

curl -v --request PUT --header "PRIVATE-TOKEN:$ACCESS_TOKEN" -F "branch=master" -F "author_email=email" -F "author_name=mea" -F "content=<path/to/local/file" -F "commit_message=testing the api" "https://repo/api/v4/projects/$PROJECT_ID/repository/files/db.sql"

Hi @RafaelMoreiraSkrey

@snim2 usage is the correct one

From a curl man page:

This enables uploading of binary files etc. To force the ‘content’ part to be a file, prefix the file name with an @ sign. To just get the content part from a file, prefix the file name with the symbol <. The difference between @ and < is then that @ makes a file get attached in the post as a file upload, while the < makes a text field and just get the contents for that text field from a file.