How to download specific files from a Bitbucket repository
Platform Notice: Cloud Only - This article only applies to Atlassian apps on the cloud platform.
Summary
This guide provides step-by-step instructions on downloading files from a Bitbucket cloud repository using either the Bitbucket Cloud UI or the API v2.0 endpoint.
Solution
Option 1 - Download the file via the UI
Navigate to the file(s) in the Bitbucket Cloud Repository UI by selecting the Source tab.
Open the files you want to download.
On the right side, select the ... button.
Select Open Raw.
Opening the file in Raw will automatically download it. If you want to download code/text or anything other than binary files, you'll need to manually save it by right-clicking and using your browser's "Save As" option.
Option 2 - Download the file via the cURL utility
ℹ️ Before proceeding, ensure you have the following prerequisites: Workspace ID, Repository URL, Branch Name, and API token with at least the read:repository:bitbucket scope.
Follow these steps:
Locate the files you want to download from the Source tab in the Bitbucket Cloud repository.
Use the following example cURL command to download the file:
curl -s -S --user <atlassian_account_email>:<api_token> -L -O https://api.bitbucket.org/2.0/repositories/<WorkspaceID>/<RepoName>/src/<BranchName>/<FolderName>/<FileName>
Replace the placeholders in the command with your specific information:
<atlassian_account_email>
: Your Atlassian account email address.<
api_token
>: An API token with at least the read:repository:bitbucket scope.<
WorkspaceID
>
: The ID of the Workspace where the repo belongs.<
RepoName
>
: The Repository slug.<
BranchName
>
: The Branch name.<
FolderName
>
: If the file is in a folder, provide the folder name; otherwise, omit this from the URL.<
FileName
>
: The file's name, including the file extension, for example:myfile.txt
.
If the above instructions do not assist you with downloading files from your repository, please raise a support ticket or raise a community support ticket for further assistance with this.
Was this helpful?