Srikanth R
Srikanth R

Reputation: 3

How to Upload a folder to bitbucket repo using API and CURL

I'm able to upload a file to bitbucket repository but there is any way to upload a folder using CURL and API.

Upvotes: 0

Views: 2194

Answers (1)

Core PCN
Core PCN

Reputation: 21

The API is thinly documented, but this is what works for me:

Using cURL:

curl --user <username:password> -X POST https://api.bitbucket.org/2.0/repositories/<workspace_name>/<repository_name>/src -F <local_file_name.ext>=@<destination_filename.ext>

For a username of "Foo" and password of "Bar", in my workspace called "widgetcentral", a repository named "testRepo", local filename of "sampleFile.txt" I would do

curl --user Foo:Bar -X POST https://api.bitbucket.org/2.0/repositories/widgetcentral/testRepo/src -F [email protected]

One caveat, this seems to upload only to master, I can't get it to upload to any branch.

Upvotes: 1

Related Questions