Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

How to commit multiple files from memory using bitbucket API?

Hello I have been able to upload files to bitbucket cloud by saving them first to my disk and then commiting them one by one to my repository via the API, but I haven't been able to send files that are in memory and I haven't been able to send multiple files which should get committed to different folders at the same time.

Does anybody know how to do this?

I am writing my api functions in python using the requests library.

1 answer

0 votes
Syahrul Atlassian Team Nov 23, 2021

Hi @Kurt Rhee 

Welcome to the community!

If I got this right you wish to use the API to create commit on multiple files from memory? If yes, I believe the following curl API endpoint can be used with the content type of multipart/form-data to commit multiple files:

curl --request POST \
  --url<WorkspaceID>/<RepoSlug>/src \
  --header 'Authorization: Basic cm9.....==' \
  --header 'Content-Type: multipart/form-data' \
  --form 'message=my commit message' \
  --form branch=<branch name> \
  --form file1=@<My First File Path>\
  --form directory/file2=@<My Second File Path>

As for using python, I am not an expert on this, but from my research on how to POST a file with Python and I found the following example:

import requests
from requests_toolbelt.multipart.encoder import MultipartEncoder

m = MultipartEncoder(
            'branch': 'dev', 
            'message': '<Your MESSAGE>',
            '/path/file1': ('filename', open('', 'rb'), 'text/plain'),
            '/path/file2': ('filename', open('', 'rb'), 'text/plain'),}
r =, data=m, headers)

I hope this helps!


Hello this is very helpful thank you!

Like Syahrul likes this

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bitbucket

Git push size limits are coming to Bitbucket Cloud starting April 4th, 2022

Beginning on April 4th, we will be implementing push limits. This means that your push cannot be completed if it is over 3.5 GB. If you do attempt to complete a push that is over 3.5 GB, it will fail...

2,265 views 2 9
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you