Files are typically uploaded to a remote git repository using
git push, however, Bitbucket also supports uploading files using a REST API.
Prerequisites[edit | edit source]
- Complete the Bitbucket/Get Started tutorial to create a Bitbucket account and learn how to create a repository and add files.
- Create a repository.
Readings[edit | edit source]
Upload a File to the Downloads Folder[edit | edit source]
Bitbucket has a Downloads folder which supports uploading and downloading files. This provides easy uploading and downloading, but files are not part of the repository source.
- Using the Bitbucket website, select the repository.
- On the left, select the Downloads folder.
- Select Add Files to add files. Files may be accessed or referenced using the full file URL.
Upload a File Using cURL[edit | edit source]
Files may be uploaded as source files using a command-line interface (CLI). Users comfortable with a CLI may use cURL.
- cURL is included in Linux and macOS. Windows users must download cURL from Haxx.se: curl or use a tool that includes it (such as Git Bash).
- Open a terminal or command prompt window and navigate to the folder that contains the file to be uploaded.
- Use the following command to upload a file, replacing the username, password, account name, repo path, and filename:
curl -u username:password -X POST https://api.bitbucket.org/2.0/repositories/myaccount/myrepo/src -F email@example.com
- Check your Bitbucket repository to verify that the file was uploaded successfully. Note that some files may take up to several minutes to appear.
Examples[edit | edit source]
- Upload example.jpg to the root folder:
curl -u example:pass -X POST https://api.bitbucket.org/2.0/repositories/example/example.bitbucket.io/src -F firstname.lastname@example.org
- Upload example.jpg to the assets folder with a different filename:
curl -u example:pass -X POST https://api.bitbucket.org/2.0/repositories/example/example.bitbucket.io/src -F email@example.com
Upload a File Using Insomnia REST Client[edit | edit source]
Files may be uploaded as source files using a REST API. Users preferring a graphic user interface (GUI) may use the Insomnia REST client.
- Download and install Insomnia from Insomnia: REST Client.
- Run Insomnia.
- Create a new request. Name the request
Bitbucket Upload, select
POSTas the request type, and
Multipartas the content type.
- At the top, enter
https://api.bitbucket.org/2.0/repositories/myaccount/myrepo/srcfor the URL, replacing myaccount and myrepo with your Bitbucket account and repository name.
- Under Multipart, enter
filename.extfor the new name, replacing
filename.extwith the filename and extension of your file. Select
Fileas the value and use
Choose Fileto select the file.
Basic Authand enter your Bitbucket username and password.
- Send the request.
- Check your Bitbucket repository to verify that the file was uploaded successfully.