Closed HarisHashim closed 5 years ago
Possibly related to #6 and #47
By default if you don't provide an id to be used as a key in the store this module tries to infer the extension from your data URI. Since it is of mime type application/octet-stream
this is expected behavior to select a bin
extension according to https://github.com/jshttp/mime-db.
If you'd like to keep the extension you should probably try to be more specific in your data URI, eg https://github.com/jshttp/mime-db/blob/master/src/apache-types.json#L1689, or provide a custom ID.
Let us know if it works.
Thanks @claustres for the answer. I don't really understand since I am quite new.
Is there sample code to show how to customize the filename and extension to save? Maybe showing how providing an id is to be done?
It turns out that I submit file extension from frontend in that particular REST call. So it is easy for me to tell the store or feathers blobs what extension should be used.
I also plan to append some info to the saved filename.
Thanks and really appreciate it!
Tests are always a good way to learn or have sample code: https://github.com/feathersjs-ecosystem/feathers-blob/blob/master/test/index.test.js#L87.
Thanks! That sure clear things up.
Reopen if required, thanks.
Steps to reproduce
"data:application/octet-stream;base64,UEsDBBQABgAIAAAAIQCz8LkduwEAAFwIAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCCiBAIooAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA ... (continue lots of stuff)"
Expected behavior
Expected file is saved with docx extension.
Actual behavior
It is saved in upload folder with .bin extension
System configuration
Module versions (especially the part that's not working):
NodeJS version: v8.11.2
Operating System: Win 10 Pro
Browser Version: Google Chrome Version 73.0.3627.0 (version does not matter)
Code Structure:
I have uploads.service.js (generated by feathers cli) that have before create hook named createBlob.
createBlob calle blobs service using bellow code:
My code for blobs.service (generated by feathers cli) as follows