Fix NoMethodError for Files API
What does this MR do and why?
Contributes to #468699 (closed)
Problem
Files API does not handle a case with base64 encoding when file content is missing. It raises a NoMethodError.
Solution
Apply Base64 decoding to non-empty content only.
How to set up and validate locally
curl --request POST \
--header 'PRIVATE-TOKEN: <token>' \
--header "Content-Type: application/json" \
--data '{"branch": "main", "author_email": "author@example.com", "author_name": "Firstname Lastname",
"content": null, "encoding": "base64", "commit_message": "create a new file"}' \
--url "http://gdk.test:3000/api/v4/projects/2/repository/files/new_file"
Before
{"message":"500 Internal Server Error"}
After
{"file_path":"new_file","branch":"main"} # 200 OK
Edited by Vasilii Iakliushin