feathersjs-ecosystem / feathers-blob

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

[Question] Data uri VS Raw data buffer #95

Closed victor-gabou closed 2 years ago

victor-gabou commented 2 years ago

Hello,

Not a bug here :)

I was just wondering what are the difference between using data uri or raw data buffer

I've been using feathers-blob for several years and as I always used the feathers doc when starting a project, I've used data uri every times.

But as I'm starting a new project, I wonder if raw data buffer is better (or worst) than data uri and what are the pros and cons.

My main concern is performances.

Thanks for your work!

claustres commented 2 years ago

Data URI is a way to directly include the data in-line in your web page. So it is pretty convenient if you'd like to store eg images as you can directly display the result of the service without requiring the image file to be publicly available.

I think raw data buffer is more adapted if you'd like to store things not to be directly displayed eg a PDF. You can then create a blob directly from the buffer to provide the user with a way to download it.

claustres commented 2 years ago

Maybe another difference is about the protocol which is best adapted to both approach. When using websocket you don't really have any problem to transfer a big buffer but when using raw HTTP it can be more complicated and requires multipart upload, which might be more easy to deal with using data URI. However I am not sure about that as you can use a blob with a raw buffer in a multipart upload.

victor-gabou commented 2 years ago

Thanks a lot for these informations!

To sum up, as I'm working on a generic file input, the best would be to return files as data uri as it's more convenient with a rest approach (and not problematic with sockets) + it allows me to display selected files (if images) directly before submitting them to server. For the file download case, as it's not complicated to transform data uri to blob on client I don't think that I should take this into consideration.

Does this sound like the right approach to you?

claustres commented 2 years ago

That's exactly what I am doing actually, so it sounds good to me ;-)

victor-gabou commented 2 years ago

Perfect, thanks for your replies :)