question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Filesystem.WriteFile doesn't save file correctly

See original GitHub issue

When saving a file, other than text, it does not display properly in the android file system.

Often when using FileReader.readAsDataURL to create a string from a Blob a header is also created. The android system does not recognize this seemingly or he is formatted wrong, I do not know …

Solution.

Removes the header before creating the file.

   //remove header
    const split = data.split(',')[1]; //data:image/jpeg;base64,AUIDUHIWad....
    data = split[1] || data;

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
GuilhermeBCCcommented, Jan 17, 2019

Correcting

if(data.indexOf(',') != -1){
   data = data.split(',')[1];
}
0reactions
jcesarmobilecommented, May 7, 2019

I’ve fixed it here https://github.com/ionic-team/capacitor/pull/1473

@mhjam, please, if you find issues report them on https://github.com/ionic-team/capacitor/issues as a new issue instead of commenting in old issues. Comments on old issues might be missed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

fs.writeFile has no errors, but fails to write file - Stack Overflow
the problem is because this call is async and probably is loosing the context right after, I was able to fix it on...
Read more >
5 Effortless Steps to Fix "failed to write file to disk" in WordPress
Now that the folders are fixed, it's time to verify the files are set correctly as well. Right click the wp-content folder and...
Read more >
How to Fix the "Upload: Failed to Write File to Disk" Error in ...
Is your WordPress site showing the "Upload: Failed to Write File to Disk" error? Bummer, but it's an easy fix. Check out these...
Read more >
fs.writeFile() doesn't work properly - Replit
writeFile (); works only as long as someone is editing the project. After that it still edits and works but it resets to...
Read more >
File system | Node.js v19.3.0 Documentation
writeFile (data, options); filehandle.writev(buffers[, position]) ... fs.write(fd, buffer[, options], callback); fs.write(fd, string[, position[, encoding]], ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found