Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

bitbucket API sending text file to bitbucket

cnshum_2019
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 19, 2022

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
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 24, 2022

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
Product Admin
TAGS
AUG Leaders

Atlassian Community Events