Create/Remove Folders Programmatically --> any similar function like CreateBucket()?

By default ListObjects lists non-recursively. Depending on your use-case you may want to do a recursive listing, which basically lists all objects in the bucket. For example:

objects := project.ListObjects(ctx, buckets.Item().Name,
    &storj.ListObjectOptions{
        Recursive: true,
    })

The alternative is to list by specifying a prefix:

objects := project.ListObjects(ctx, buckets.Item().Name,
    &storj.ListObjectOptions{
        Prefix: "kraken/",
    }))

Of course they can be combined into:

objects := project.ListObjects(ctx, buckets.Item().Name,
    &storj.ListObjectOptions{
        Prefix: "kraken/",
        Recursive: true,
    })

With regards to:

kraken/ true &{ada 2021-11-23 14:57:06.194679 +0000 UTC}

That’s an ephemeral entry for the prefix. They aren’t actually stored anywhere. This “pseudo-entry” is needed to support hierarchical navigation of the objects.

When you use “Recursive: true” then those won’t be shown since they aren’t needed.

Forum is probably a good place to ask such questions. It means other people can find them. Discord and other chats are less discoverable.

3 Likes