Add custom file uploads to REST API (BB-1315)

Issue #3251 resolved
Dylan Etkin
created an issue

The download page allows you to upload custom artifacts for your repo. This is not available through the api. To script this, you currently have to reverse engineer the form on the download page and post directly to it. This is a hassle as it's posting straight to S3 and requires 6 hidden fields, one of which is a one-time key.

Comments (67)

  1. Anonymous

    I would like to add my "vote" to this. I use Bitbucket to maintain my website which contains a repository of my site's files, but also a backup of my MySQL database as a separate download. Currently I have to upload this backup every day manually and I was hoping to be able to use the API to automate this.

  2. Steve Rukuts

    +1: It would be really handy to integrate this with our build system so we can automatically upload a preview build every day or two so we can get notes from our users.

  3. Alex Dupuy

    +1 Upload bandwidth from my browser through the regular web interface is too low to be usable for large (~1GB) files; hopefully an API access would be faster (and easier to script from my servers in the cloud).

  4. John Sirach

    I saw in an other post that there was a planning for this, but this was in 2011, it is now 2014. I now have opened up my local jenkins builder where people can download snapshots. But this is a dsl connection and not really that fantastic.

    So what is the status of this quite old request?

  5. Christian Tismer


    To the Atlassians: It would be even useful if the upload button's open dialog would allow to mark multiple files. Probably simpler and easy to do than a full API for that. Right now I have to upload 32 files, which takes much time, because I have to wait for every single upload to finish.

    Anything would be great that allows me to start the upload and then go away.

  6. Bernie Zhao

    I truly like BB but the lack of download notes, bulk operation, is really painful. GitHub offers Releases which might be a good model. Please tell us you have this on your roadmap. Thanks.

  7. EvertX

    Waiting for this for a long time. I am not sure how issues are processed, but given that it has high priority and is in the 19th place when it comes to number of votes on the list of issues, I have hope it will be dealt with soon now.

  8. Jobin Jose

    For DB backup purpose simply write a bash script for auto upload, that is what I'm doing.

    I'm already using automysqlbackup package for debian. It will create a compressed db backup in output directory path, I just initialized that output directory with a git init and set it remote to a BB repo. I'm already SSH verified so no password prompt for push/pull.

    Then simply create a bash file with following code.

    cd /home/phpadmin/Development/DB_backup ;
    git add -A ;
    git commit -m "Auto DB backup push" ;
    git push orgin master;

    Next step is to set up the cron job for this bash script file, save this file in somewhere and set the correct path make sure it have execute permission. Done! mydb backup upload automatically to my BB account.

  9. Swyter

    It's pretty clear that they aren't going to do anything, if you want to upload files automatically for things like CI use this Bash script I created that someone already posted before:

    There's a PowerShell version, a Windows console version and a Bash version, contributed by other people. It's tiny and actual projects like PyPy make use of it.
    If you don't want to use it may still work nicely as quick reference to see how to do it. You only need cURL and a few lines, including login.

    Easier than an API, albeit still unsupported. There's no excuse for the stagnated development from Atlassian, but at least there are some workable solutions if you are stuck with Bitbucket.

  10. James Low

    @Swyter Thanks for that; looks like a work around for now. I've added a link back to this feature request if you'd like to merge my changes in the pull request.

    This issue has been marked as priority "major", so maybe they are aware of the need, but it doesn't have anybody assigned.

  11. Erik van Zijst

    Sorry for not closing this issue earlier. Files can be uploaded to the "Downloads" artifact tab directly from the command line via the API.

    To upload files, perform a multipart/form-data POST containing one or more files fields:

    $ echo Hello World > hello.txt
    $ curl -s -u evzijst -X POST -F files=@hello.txt

    When a file is uploaded with the same name as an existing artifact, then the existing file will be replaced.

    Note that this very similar to how the snippets API works, which also supports standard multipart/form-data file uploads

    This is a normal API endpoint, supporting all authentication schemes. My example uses HTTP Basic Auth, but be aware that this is incompatible with the use of 2-step-verification, so consider OAuth 2 or an API Key if 2-sv is important to you.

  12. Maxim Novikov

    I guess, until it's documented, people will not know about its existence and will continue creating issues regarding the same stuff. My personal understanding of a finished feature is that the customer may find out about it and how to use it from the official documentation. If it's not there, there is no feature to use.

  13. Daniel Stevens

    Hello everyone,

    I'm the writer for Bitbucket and I agree if it's not documented it doesn't exist. I won't make any excuses, the REST docs are WAY behind. I will, however, commit to changing that in the next few weeks. Starting with this resource: downloads resource.

    I hope you will see a marked improvement with the REST API docs completeness very soon.

    Have an exceptional day, Daniel Stevens

  14. Alexander Straube


    thanks for pointing out how to upload files to Bitbucket's Downloads section. I managed to upload files by using my real account credential like curl -X POST "" --form files=@"myFile.txt" or with an app password like curl -X POST "" --form files=@"myFile.txt"

    But is there a way to reuse pipelines $AUTH_TOKEN or {access_token} variables? Following occurs during "Build setup" step: git clone --branch="master" --depth 50 https://x-token-auth:$ $BUILD_DIR && git reset --hard 581b855s4d718c83f88947a0d85b7e5747c7e12b && git remote set-url origin https://x-token-auth:{access_token} EDIT: I already tried using curl -X POST "https://x-token-auth:{access_token}" --form files=@"myFile.txt" and curl -X POST "https://x-token-auth:$" --form files=@"myFile.txt" but without success (always got curl: (22) The requested URL returned error: 401 UNAUTHORIZED)

    Thanks and best regards, Alexander Straube

    EDIT: Alright, I managed to make it a bit more secure by moving the myusername:myAppPassword part to a secured Bitbucket variable and referencing it by using $MY_AUTH_STRING like curl -X POST "https://${MY_AUTH_STRING}" --form files=@"myFile.txt" but it still would by nice to have a solution without having to define a new Bitbucket variable and using existing AUTH_TOKEN / access_token

  15. Dave Braunschweig

    Including username and password in the URL no longer works on macOS. The following may be used to upload an image to Bitbucket source instead:

    curl -X POST -u username:password "" --form filename.png=@filename.png
  16. Log in to comment