I am trying to commit a file to Gitlab through the API. The format of the file is .mp3.
The code had been working for over 6 months but now has stopped working, nothing in the code had changed. The file is commited to Gitlab, however the mp3 format has changed and I cannot play it anymore.
I have went through the Guzzle documentation and everything looks correct, and I have done the same for the Gitlab documentation about commits. I updated guzzle as well.
I am now using the laravel Illuminate/Http class to send the commits but the same thing is still happening. I am able to commit to Gitlab, but the mp3 file is not formatted correctly.
$response = Http::withHeaders([ 'PRIVATE-TOKEN' => $gitlab_token, ]) ->post('https://gitlab.com/api/v4/projects/.../repository/commits/', [ 'branch' => 'test-branch', 'commit_message' => 'Updated audio file test.mp3', 'actions' => array(array( 'action' => 'update', 'file_path' => 'filePath/../.mp3', 'content' => base64_encode($var) ) ), ]);
If I do not encode the contents of the file to base 64 I get the error:
Malformed UTF-8 characters, possibly incorrectly encoded in file
Has anything changed on the API side that has effected how mp3 files are processed for committing? has anyone else found a solution (perhaps a Laravel or php helper function?). Thank you!