Programmatically list all keys and items within a Bucket for dynamical up-/download and further processing

Hi all,

for my project I need to list all files within a bucket on a one hand to process them, on the other to upload new files with accordingly incremented filenames. At this point I am totally flexible in terms of incrementing either keys or the filenames, to provide unique identification for all stored items.

For now I am able to create new buckets, theoretically add there keys and store there files, but I am not able to list all those keys and filenames, that’s why theoretically.

Appreciate any help :slight_smile:

In addition, it’s quite interesting, how do you access and display the whole structure in the web client. There are buckets, folders assigned to those buckets and files within those folders.

First of all - there is no folders and files :slight_smile:
The “folders” (prefixes divided by slashes) is a part of the object key (name).
To list all objects in the provided bucket you can use uplink CLI:

uplink ls --recursive sj://my-bucket

You can check the code, how the --recursive implemented and can use the similar approach in your code.

The way to upload a folder with files to the bucket:

$ find Documents/other/swarm -type f -exec uplink cp '{}' sj://test/'{}' ';'

First of all - there is no folders and files :slight_smile:

I think you must put it into the Storj Bible :slight_smile: In my previous thread I did the same mistake → from now I will use only the conventional Storj naming.

Jokes aside… Where did you put the CLI repository? I know, that sounds absolutely dumb, but I cannot find its implementation.

1 Like

I’ve got further instructions on how to iterate over the items in my other post → Create/Remove Folders Programmatically --> any similar function like CreateBucket()? - #11 by Egon

That’s exactly the solution for my problem described here. Ticket solved :wink: