Update bucket and Rename Bucket
mircea-pavel-anton opened this issue · 3 comments
Feature request
Is your feature request related to a problem? Please describe.
At the current point in time, there is not a way to rename a bucket, as far as I can tell.
Describe the solution you'd like
Maybe we could create a wrapper function, something like:
async renameBucket(oldName : string, newName : string) {
this.createBucke(newName);
// move all files from old bucket to new bucket
this.deleteBucket(oldName);
}
Since the updateBucket(...)
method only updates the options
, as far as I can tell.
Maybe we could rename them to updateBucketName
and updateBucketOptions
to make the use-case more clear.
Describe alternatives you've considered
I wouldn't say this is a mandatory addition, as it could easily be implemented by the developer using this, but it could be a quality-of-life improvement to have it handled on our side.
Renaming a bucket can be a pretty expensive operation if your bucket has thousands of objects since they need to be moved to a different location in the underlying storage (s3) as well. Since this can take minutes to do, we won't be able to offer an API which does this atomically.
So there is no way to rename the bucket? Even if I don't want to move everything to a new bucket? And looking for a simple rename?
@bennik88 If you just want to rename the bucket and don't care for it's contents? simply delete it and create a new one. You can write a helper function yourself, something along the lines of:
async renameBucket(oldId: string, newId: string) {
await storage.emptyBucket(oldId); // in case the previous bucket had some files in it
await storage.deleteBucket(oldId);
await storage.createBucket(newId);
}