How can I Upload entire directory to bitbucket repo via cloud API

Andre Pilakis
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!
January 31, 2023

Hello, I have an existing repo and would like to add an entire directory to it.

I am following this from the docs: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-source/#api-repositories-workspace-repo-slug-src-post

I am successfully able to add a single file with the following request:

curl --user $user:$password \
 -X POST https://api.bitbucket.org/2.0/repositories/$workspace/$repo_name/src \
 -F helloworld.txt=@helloworld.txt
Now lets say I had a directory named "mydir" which had multiple files inside it, Is there a way I can upload that entire directory, or the contents of the directory with one API call?

2 answers

0 votes
Ben
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 1, 2023

Hey Andre,

Unfortunately, wget/cURL does not have the concept of what a "folder" is in this context.

They can be used to upload individual files as you have stated - but they are unable to upload entire folders in a singular command.

You would need to write a bash script to cycle through each individual file in that directory to achieve what you wish to do.

Cheers!

- Ben (Bitbucket Cloud Support)

0 votes
Ulrich Kuhnhardt _IzymesCo_
Atlassian Partner
February 1, 2023

Hi Andre,

first thing that comes to mind is to use git add, git commit and git push to add a directory to a BB repository. The commands can run as a script if you need to automate. However I'm not sure about your specific use-case.

Best, Ulrich

// Izymes

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events