1. Bitbucket
  2. Public Issue Tracker
  3. master
  4. Issues

Issues

Issue #3251 resolved

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

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 (64)

  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. Alexander 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

    +1

    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. Bert Visser

    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:

    https://bitbucket.org/Swyter/bitbucket-curl-upload-to-repo-downloads

    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 staff

    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 https://api.bitbucket.org/2.0/repositories/evzijst/git-tests/downloads -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

    P.S.
    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. Dan Stevens [Atlassian] staff

    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. Log in to comment