Problem Description:
I am trying to upload binary artifacts to a GitLab repository using the GitLab API. The upload appears to succeed based on the API response, but the files in the repository are not of the expected size. Instead, they are 56 bytes and contain the text:
#<ActionDispatch::Http::UploadedFile:0x00007fba5dff2a98>
Current Setup:
I use a curl command in a CI/CD pipeline to upload the files as follows:
curl --request POST \
--header "PRIVATE-TOKEN: $TARGET_PROJECT_TOKEN" \
--form "branch=$TARGET_BRANCH" \
--form "commit_message=Upload Linux artifact" \
--form "actions[][action]=create" \
--form "actions[][file_path]=bin/$OS_ARCH/libtest.so" \
--form "actions[][content]=@${ARTIFACT_PATH}" \
"https://gitlab.inria.fr/api/v4/projects/$TARGET_PROJECT_ID/repository/commits"
Variables:
ARTIFACT_PATH1points to a binary file (e.g.,artifacts/libtest.so) of size 256 KB.$OS_ARCHevaluates tolinux-x86_64.$TARGET_PROJECT_TOKEN,$TARGET_BRANCH, and$TARGET_PROJECT_IDare set correctly.
Observations:
-
File Size Issue:
The file in the repository is only 56 bytes, whereas the original file is 256 KB. -
Content of the Uploaded File:
The uploaded file’s content in GitLab is:#<ActionDispatch::Http::UploadedFile:0x00007fba5dff2a98> -
API Response:
Thecurlcommand indicates success with the following output:% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 256k 100 761 100 255k 274 94492 0:00:02 0:00:02 --:--:-- 94732
Question:
Why does the uploaded file contain #<ActionDispatch::Http::UploadedFile> instead of the actual content of the binary file?
Additional Information:
- GitLab version: 17.7.0
- CI/CD runner: self-hosted
- OS: Ubuntu
Any help or guidance would be greatly appreciated!