can not readFile that captured as tmpfile
See original GitHub issuereadFile() method of both “react-native-fs” and “rn-fetch-blob” works well for static asset files or the output of “react-native-camera” library. But the readFile() method can not read the file that captured via “react-native-view-shot” as tmpfile.
react-native@0.52.2 react-native-view-shot@2.3.0 react-native-fetch-blob@0.10.8 rn-fetch-blob@0.10.11 react-native-fs@2.10.14
class SomeComponent extends Component {
async captureAndReadFile() {
try {
let filePath = await this.viewShot.capture() ;
let data = await RNFS.readFile(filePath, 'base64'); // or RNFetchBlob.fs.readFile(filePath, 'base64');
return data && new Buffer.from(data, 'base64');
}
catch(err) {
console.warn(err);
}
}
render() {
return(
<View>
<ViewShot
ref={ref => this.viewShot = ref}
options={{ format: 'jpg', quality: 0.8 }}
/>
<Button title="Press" onPress={this.captureAndReadFile.bind(this)}
</View>
);
}
Am I missing something ? Thanks in advance.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:8 (4 by maintainers)
Top Results From Across the Web
eclipse: Project not built due to "Could not read file
With the existence of this temp file, eclipse failed to build my project. The problem window said: The project was not build due...
Read more >why php can not see /tmp files - Unix & Linux Stack Exchange
I am running Ubuntu 18.04 and /usr/lib/systemd did not contain any services for http or apache2. However, I executed the following command:
Read more >Execute failed: Cannot read file ...
Encountered this very scary error with a long-running workflow during the night occurring at the “Table Row To Variable Loop Start” node.
Read more >How to use Temporary Files in C# - Dave on C-Sharp
Create a new Console Application and add a method called CreateTmpFile . In this method we will use the System.IO.Path class to create...
Read more >Fix errors that relate to reading or creating files in the temp or ...
To correct this problem you may need to change your environment variable for $TMP or $TEMP, to somewhere you have write access. You...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @gre ! I think this bug is still active.
Expo.takeSnapthosAsync
has this bug in Expo 31 compare to Expo 30 (iOS tested). In Expo 31takeSnapthosAsync
was updated to usereact-native-view-shot
v2.5.0, and nowtakeSnapthosAsync
result “tmpfile” uri is not compossible withExpo.MediaLibrary
orExpo.FileSystem
any more. That is because “tmpfile” uri path is in/private/var/...
andExpo.MediaLibrary
andExpo.FileSystem
can only work with paths that are in public system scope/var/...
. When you try to save taken view snapshot to user photos or temporary dir, you will see an error “Couldn’t read …”.As I remember in Expo 30 version of
react-native-view-shot
was something around v1.1.0.I think this is fixed. I was properly able to get the data from file and render it back in https://github.com/gre/react-native-view-shot/commit/8a6ea61c300d4ee7cb4fae2b9eec28d3c0b95dfe
works on iOS and Android.
Please report back if you are still having an issue (writing an example to reproduce the bug is the best)