itinance / itinance/react-native-fs

Write ignore position if file is not already created

Open
#1,056 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
C++
Stars
5k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

I'm trying to write a file chunk by chunk.
i receive chunks asynchronously so i perform some write with position in this way:

`await RNFS.write(path, payload.toString('base64'), position, {encoding: 'base64'});`

I found a bug into the position handling when the file is not already created. In this case the library write the payload in a file, starting from 0.
If the file is already present (i created it with `writeFile` i.e.) it works as expected, from 0 to position it set 0 and then the payload.

## Sample

```javascript
await RNFS.write(path, 'payload_2', 10);
await RNFS.write(path, 'payload_1 ', 0);
```

### Expected results

`payload_1 payload_2`

### Results

`payload_1 `

the `payload_2` get overridden since it was written into the position 0 instead 10

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.