Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

How can we upload files into a folder on BitBucket Downloads

As per title. Is that possible? 

 

This is essential for file management.

1 answer

0 votes
Ben
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Mar 16, 2022

Hey Wen,

You are able to upload files to your repository downloads folder by using our /2.0/repositories API, please note you will need to configure and use an App Password to perform this for authentication purposes.

For example, substituting "pathtofile" with file path and entering workspace/repo slug with App Password substituted in for the header:

curl -X POST -F files=@/pathtofile/filename.extension  \

  --url https://api.bitbucket.org/2.0/repositories/WORKSPACEID/REPOSITORYNAME/downloads \

  --header 'Authorization: Basic APPPASSWORDHERE' 

 

Hope this helps.

Cheers!

- Ben (Bitbucket Cloud)

Hi Ben, I am only able to upload 'files' in the 'downloads' folder, I want to upload a folder in either downloads folder or a folder under downloads folder.

Ben
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Oct 03, 2022

Hey Krishna,

If I am understanding you correctly - you wish to upload an entire folder, rather than just individual files correct?

Unfortunately, this is not possible with a single command, as it is not possible to create a folder within the Downloads directory.
I would suggest either:
a) Compressing the folder into a zip file and uploading this
b) Create a bash script to cycle through all files within the folder and upload these in bulk
c) Uploading all files within the folder via the UI - this allows for bulk selection of files

Cheers!

- Ben (Bitbucket Cloud Support)

Hi @Ben 

Thanks for your reply, I didn't understand the suggestion.

How would the bash script help if we cannot create the folders in downloads section?

Point c, where shall I upload all the files via UI, I want the files to be in a folder and not directly on downloads.

Also I wanna do this in pipeline, so can't upload manually.

Approach I have taken: using another repo for uploading the folder, cloning it and then adding the artifacts and then pushing the changes.

Ben
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Oct 05, 2022

Hey @Krishna Kumar Singhal 

Given that your request was asking how to upload a folder to Bitbucket Downloads section specifically (which is not possible), I had provided some alternatives for getting all of the required files uploaded to the Downloads section.

Regarding the UI, if you are intending to use Pipelines this will rule out using the UI at all. 

I'm glad that you were able to find a solution, however.

Cheers!

- Ben (Bitbucket Cloud Support)

@Ben I want to use a pipeline to the same but I want to specify a list of files instead of a single file or directory. How should I format the `FILENAME` value to achieve that?

Ben
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 08, 2023

Hi @daw not possible, unfortunately - as mentioned previously, it is not possible to do this in a single command. I would suggest authoring a bash script to upload files one by one, you could use an array variable that contains all the filenames and make use of a for/while loop to cycle through this array.

Cheers!

- Ben (Bitbucket Cloud Support)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events