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
4,363,594
Community Members
 
Community Events
168
Community Groups

bitbucket API sending text file to bitbucket

Hi all,

I have a django application which has the function of pulling files from s3 bucket using boto3 and pushing it to bitbucket. I understand that theres a post api which allows me to send files into bitbucket. this is an example of the post api

$ curl https://api.bitbucket.org/2.0/repositories/username/slug/src \ -F /repo/path/to/word.txt=@word.txt

for the part after the @, what do i include after it since the file retrieved from s3 is in a json format

1 answer

0 votes

Hi @cnshum_2019 and welcome to the community.

In the -F argument, the part after @ should be the path to the file and the name of the file on your machine (the one where you have downloaded this file and where you are executing the curl command).

If the file on your machine is named myFile.json and it exists in the current working directory (where the curl command is running), you can simply put myFile.json


The part /repo/path/to/word.txt is the path of the directory in the repo where you want to upload the file, and also the name you want this file to have once uploaded to the repo.

If you want to commit the file to the root of the repo, and you want to name it myFile3.json, then you simply put myFile3.json instead of /repo/path/to/word.txt. You could also keep the same name as locally.

The following call will commit your local file named myFile.json in the repo, and the file will have the name myFile3.json once uploaded to the repo.

curl https://api.bitbucket.org/2.0/repositories/username/slug/src -F myFile3.json=@myFile.json

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Site Admin
TAGS

Atlassian Community Events