tweedegolf / storage-abstraction

Provides an abstraction layer for interacting with a storage; the storage can be local or in the cloud.
MIT License
106 stars 18 forks source link

Revert: store selected bucket in local state #53

Closed abudaan closed 7 months ago

abudaan commented 8 months ago
          I have just read through the migration document. I had a query on some of the design decisions for the new API, particularly around how the bucket name is used. It looks as though I can specify the bucket name in the storage URL still (which is great, that's how we want to use it as it keeps our config very simple as just a single url), but then the strange bit, it looks like I also have to re-specifcy it in every call on the storage adapter? This seems a bit weird and unfriendly as I already specified it. Maybe I've misunderstood the change?

I'd expect that if I've specified the bucket in the URL of the storage setup then that's the ONLY bucket I can access through that particular storage instance (credentials are likely tied to that bucket anyway). At the very least it should be used as the default if I omit the bucket name in later storage API calls. If I don't specify the bucket in the storage constructor then it makes sense to require it on every later API call.

Secondly the changes in the URL format, was there a reason behind diverging away from the more known s3://buckname/path/to/object type URIs that the AWS cli supports?

Originally posted by @headlessme in https://github.com/tweedegolf/storage-abstraction/issues/46#issuecomment-1900322465

abudaan commented 8 months ago

Yes, you are right. I am reverting to storing the selected bucket in the local state of the storage/adapter instance

abudaan commented 8 months ago

I am implementing overloaded methods like this:

  abstract listFiles(bucketName: string, numFiles?: number): Promise<ResultObjectFiles>;
  abstract listFiles(numFiles?: number): Promise<ResultObjectFiles>;
  abstract listFiles(arg1?: number | string, arg2?: number): Promise<ResultObjectFiles>;

Works pretty well with code hinting in vscode.

abudaan commented 7 months ago

fixed in 2.1.0