itinance / itinance/react-native-fs
Support for writing/updating data at any given position in the file
- Dominant language
- C++
- Stars
- 5k
- Forks
- 1k
- PR merge metrics
- No merged PRs in 30d
Description
Hi, first of all, awesome library, keep up the good works! 👍👍
In our application we have an additional need for updating files (random access writes, at any given position in the file, not just rewriting and appending). We currently have this working on a custom fork and it's been battle-tested on iOS and Android for about half a year now. We now want to push this feature into `react-native-fs`, but I first want to verify a proper API for this with you. I know that you're keen on keeping the API as similar as possible to node-js, and I completely share that sentiment (although our current API is slightly different atm).
So, looking at how node-js does it, what would you think of the following API for updating files?
```
RNFS.write(filepath: string, buffer: Uint8Array, offset: integer, length: integer, position: integer): Promise
Write the buffer to filepath. Offset determines the part of the buffer to be written, and length is an integer specifying the number of bytes to write. Position refers to the offset from the beginning of the file where this data should be written. If typeof position !== 'number', the data will be written at the current position.
```
Do you consider this a good API for random access writes?
Looking forward to your feedback!
Cheers,
Hein
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.