Skip to content
This repository has been archived by the owner on Mar 16, 2019. It is now read-only.

New fs APIs make file concat and replace more efficient #56

Closed
3 tasks done
wkh237 opened this issue Jul 17, 2016 · 0 comments
Closed
3 tasks done

New fs APIs make file concat and replace more efficient #56

wkh237 opened this issue Jul 17, 2016 · 0 comments

Comments

@wkh237
Copy link
Owner

wkh237 commented Jul 17, 2016

Consider the following scenario

If we wish to concat two files or replace content of one file by another, we have to cache the file content in JS context and then write the data to destination.

const fs = RNFetchBlob.fs
fs.readFile(FILE_SRC, 'base64')
     .then((b64data) => fs.appendFile(FILE_DEST, b64data, 'base64'))
     .then(() => {  console.log(`concated ${FILE_SRC} to ${FILE_DEST}`) })

This seems not efficient especially when the file is big, that cache will likely consume up the available memory.

Therefore, I think we should make writeStream, writeFile, and appendFile accept a file path as their input, and then we can do as follow.

const fs = RNFetchBlob.fs
fs.appendFile(FILE_DEST, FILE_SRC, 'uri')
     .then(() => {  console.log(`concated ${FILE_SRC} to ${FILE_DEST}`) })
  • Add uri encoding type to writeFile
  • Add uri encoding type to appendFile
  • Test cases
@wkh237 wkh237 changed the title File support APIs makes file concat and replace more efficient APIs makes file concat and replace more efficient Jul 17, 2016
@wkh237 wkh237 changed the title APIs makes file concat and replace more efficient New fs APIs makes file concat and replace more efficient Jul 18, 2016
wkh237 added a commit that referenced this issue Jul 21, 2016
@wkh237 wkh237 added this to the 0.8.0 milestone Jul 23, 2016
@wkh237 wkh237 changed the title New fs APIs makes file concat and replace more efficient New fs APIs make file concat and replace more efficient Jul 26, 2016
wkh237 added a commit that referenced this issue Jul 27, 2016
@wkh237 wkh237 closed this as completed Jul 29, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant