rn-fetch-blob icon indicating copy to clipboard operation
rn-fetch-blob copied to clipboard

create / save file from blob

Open c-goettert opened this issue 5 years ago • 3 comments

I am using a library to create a pdf-file locally (pdfmake). The library returns the generated pdf as a blob file. Can I use rn-fetch.blob to create a file from a locally created blob? According to the docs, the supplied fetch-methods can only be used for external urls, and the writeFile method only supports encodings utf8, base64, ascii and uri. I might be mixing things up a litte, but is it possible to create a local file from a locally created blob (in memory)?

c-goettert avatar Oct 18 '19 10:10 c-goettert

@c-goettert you can create a local server to create file by pdfmake on local

pdfmake have a dev-playground dir dev-playground have server.js file

server.js provide api (url=http://localhost:1234/pdf, headers = {'Content-Type': 'application/json'}) your just need to make a form by pdfmake and do post your form to api you can get a base64 base64 have a header before a first comma you need to exclude it then you can decode leftover base64 to get pdf file finially you just need to save file

you need to install package.json

create local server command line example

node dev-playground/server.js

841020 avatar Oct 25 '19 07:10 841020

Up!

Same problem here!! I already have a blob that was generated locally and I need to transform to save on the user filesystem!!

Any ideas?

giioohbernini avatar Oct 20 '20 14:10 giioohbernini

I can not download blob file with RNFetchBlob, eg: blob:https://abc.xxx/75387739-ef58-48eb-b6df-28ca5e4190ad

fukemy avatar Jan 31 '24 02:01 fukemy