tweedegolf / storage-abstraction

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

How can I get the uploaded file's `Location` if the `addFileFromPath` method returns `void`? #17

Closed oboxodo closed 1 year ago

oboxodo commented 3 years ago

I'm looking to use this library, initially to upload files to AWS but eventually to other storage services. My spike was working until I need to get the result from uploading the file and print its Location.

I see in the S3 adapter that it uses S3's upload. That method is supposed to return an object which I can ask a Location from like this:

const data = await s3.upload(params).promise()
console.log(data.Location)

But addFileFromPath which ultimately uses that upload method, is returning void.

I understand this might've been a decision to unify the response regardless of what adapter is being used but... it would still be a good idea to allow us to access the returned object in case we need to do something with it.

abudaan commented 1 year ago

In version 1.4.5 addFileFromPath, addFileFromBuffer and addFileFromReadable return the public url if the file has been added to the bucket sccessfully.