Slynova-Org / flydrive

☁️ Flexible and Fluent framework-agnostic driver based system to manage storage in Node.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

aws s3 driver for Drive.put could return Response object, or the key.

Frondor opened this issue · comments

https://github.com/Slynova-Org/node-flydrive/blob/aea96ae1bc2995a4772391c3dc81682f9f63e500/src/Drivers/AwsS3.js#L107

Problem
Returning response.Location is limiting the app to know only that property of the result.
In cases where you're using different endpoints (for example, switching between s3 and minio servers for development), I'd rather use response.Key as the reference in DB, and then dynamically set the endpoint depending on the environment.

For example, putObject is doing it just fine
https://github.com/Slynova-Org/node-flydrive/blob/aea96ae1bc2995a4772391c3dc81682f9f63e500/src/Drivers/AwsS3.js#L163

Also, it could be considered to implement a common response object for all drivers, so you can expect always the same properties depending on which operation has been made, independently of the driver.
For instance: await Drive.put() could return a response object like

const response = await Drive.disk('s3').put(name, content, params)
response.location // full url (can be empty for local storage)
response.path // same as aws s3 response.Key - /bucket/prefix/file.jpg
response.status // 200
response.response // underlying response object if exists

I like the idea!

This package need some rewrite to be sure that output of all function are consistent (this is why #35 is still not merge btw).

If you wanna help I'd be happy to accept a PR 👍

Will start working on it next weekend 👍

Hello, I'll put this "on hold" on my part until a solution for a compact testing environment is found (docker image?)
Should I open a separate issue to track that?

Should I open a separate issue to track that?

That would be awesome! Do you have any documentation about testing with a Docker Image?

Sure, I'll create a separate issue for this

PR for this: #104