feathersjs-ecosystem / feathers-blob

Feathers service for blob storage, like S3.
http://feathersjs.com
MIT License
92 stars 32 forks source link

passing option returnUri: false and returns uri... #75

Closed guitartsword closed 4 years ago

guitartsword commented 4 years ago

Similar to this issue

Steps to reproduce

use the following config { Model: blobStore, returnUri: false }

Expected behavior

{
  "id": "filename.zip"
}

dont return uri

Actual behavior

returns uri

{
  "id": "filename.zip",
  "uri": "data:application/zip;base64,UEsDBAoAAAAAAHgnfE8AAAAAAAAAAAAAAAAQAAkAYm9vdHN0cmFwLTQuNC4xL1VUBQABxcTfXVBLAwQKAAAACAB4...."
}

System configuration

Tell us about the applicable parts of your setup.

Module versions (especially the part that's not working): 2.2.0

NodeJS version: v13.1.0

Operating System: ubuntu 18.04

claustres commented 4 years ago

Hi, could you give it a try by also setting returnBuffer: true as both are exclusive ? Could you also detail the service operation and data input you use to reproduce the bug ? Thanks

guitartsword commented 4 years ago

I want returnBuffer: false and returnUri: false, because I want to generate a Url with amazon s3 and return it

Right now im extending the service and creating one on top of this one

claustres commented 4 years ago

I am afraid this behavior is not really implemented, now these options are expected to be mutually exclusive. You can do what you want using a hook that simply removes the data uri form the context and add the required generated Url.

guitartsword commented 4 years ago

The only drawback of using a hook is that the server does the download, and I want the client to download it directly from a presigned amazon s3 link. I don't see a problem for images and small files, but with big files, the server will download the file and to send it will "upload"it (if I send the buffer or uri). This is why I want to only a send a link, for amazon to handle the bandwith directly with the client.

That's why I extended the service and changed the get functionality. I would really like to use returnUri: false and returnBuffer: false and then use a hook to send the url. This will reduce the bandwith the server uses (No download, no upload).

The only way I found was to extend this service and not call the super.get because super.get always downloads the file.

claustres commented 4 years ago

OK I see, you would like create to upload the file but not get to download it. Of course this module has been designed with symmetric operations in mind, just like a DB adapter saving the object on create and retrieving it on get. Indeed, if get does not download the data it will actually internally returns nothing, which is really strange. In your case you return the URI provided by AWS but it's a specific case not a general one.

I think that overriding the operation is the right way to go, cannot really see what we can do on the module side.

cantoute commented 4 years ago

Having same issue...

belal-mazlom commented 3 years ago

It should be fixed with this merge #82