itinance / itinance/react-native-fs

Unauthorized access error

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

Description

I am using react-native-windows for creating windows version of react app and i am trying to upload file and then create base64 data of that file.

I am using `@foqum/react-native-document-picker` to upload file. It's working fine.

And i am using` react-native-fs` to get base64 data of uploaded file.

```
const res = await DocumentPicker.pick({
type: [DocumentPicker.types.allFiles],
});
console.log(
res.uri,
res.type, // mime type
res.name,
res.size
);
var url = res.uri;

RNFS.readFile(url, 'base64')
.then((result) => {
Alert.alert("", "File Uploaded successfully.");

})
.catch((err) => {
Alert.alert("", "File not uploaded.")
});
} catch (err) {
if (DocumentPicker.isCancel(err)) {
// User cancelled the picker, exit any dialogs or menus and move on
} else {
Alert.alert("", "File not uploaded.")
throw err;
}
}
```

After File upload `RNFS.readFile` is called, this function call windows function, see attached image but this function not able to read uploaded file.

`using (var file = new FileStream(filepath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite) )`

Got unauthrozied access error.

I have add all required permision in package.appxmanifest file.

```

```

but still getting Unauthorized access error.

Please see attached image.

![windows](https://user-images.githubusercontent.com/49197416/58783190-f7ac6000-85fd-11e9-9c4f-1e8c16586c3b.png)

I have also tried `StorageFile` but this line also give same error.

`StorageFile folder = await StorageFile.GetFileFromPathAsync(filepath);`

How to solve this error.

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.