I am trying to use the Repository Files API to update an existing file, as described here. The file I am trying to update is quite big and when I try committing its contents via a PUT
request with curl
, it fails:
curl --request PUT --header "PRIVATE-TOKEN: $TOKEN" \
--header "Content-Type: application/json" \
--data "{'branch': \"$BRANCH_NAME\",
'author_email': 'me@example.com', 'author_name': 'My Name',
'content': \"$(cat path/to/file)\",
'commit_message': 'update file'}" "https://$CI_SERVER_HOST/api/v4/projects/$CI_PROJECT_ID/repository/files/path%2Fto%2Ffile"
bash: /usr/bin/curl: Argument list too long
So, my question is: how can I avoid entering the entire content of the file verbatim in the curl
command? Is there a way to read from the file directly?
(I am aware this is not an issue with GitLab directly but rather with the shell, but I am hoping for a workaround… someone has run into this before, surely?)