How to commit a image via gitlab commit API?

I want to create a commit of updating a image file in my repository. How to do it via gitlab API?

Hey @zxlc

Did you check the GitLab API documentation ? Are you having any specific issue to use this endpoint?

Does commit API supports sending binary data? Is there any sample code?

data = {
        'branch': 'master',
        'commit_message': 'some message',
        'actions': [{
            'action': 'update',
            'file_path': 'pic1.jpeg',
            'content': imageData

resp =

imageData is type of bytes, when I send this request, I received the following response:

    message: "500 Internal Server Error"

As stated in Gitlab doc, you’ll have to encode data in base64 and add encoding: "base64" to actions parameter.

Example using node-gitlab:

			commitActions = [{
				action: "create",
				file_path: filename,
				content: fs.readFileSync(file.path).toString("base64"),
				encoding: "base64"
            const response = await api.Commits.create(, "master", "Initialize datapackage", commitActions)