Comments (11)
rip, bad news:
It works as an array buffer, but not as Int8Array:
let file = bytes;
let reader = new FileReader();
reader.readAsArrayBuffer(file);
let ab = reader.result;
let byteArray = new Int8Array(reader.result)
saveSync(ab, fileName); // WORKS
saveSync(byteArray, fileName) // FAILS
So I take it back, it has to do with the lib. Ill update with link to file.
files:
https://drive.google.com/drive/folders/1x_MMMAhfWpvK4WZ0E3krS8gG1bCHlSWs
from save-file.
Ok I see. Bumped to-array-buffer, try the latest release 2.2.1. Should be fixed.
from save-file.
Brief googling suggests that may happen due to some infinite loop or another long-going process.
Do you use node.js or browser?
from save-file.
Yeah I saw that as well when I searched, I don't have any infinite loops.
I'm running in browser.
Only reason I think there could be a bug is because when I comment out, saveSync(fileByteArr, metaData.fileName);
, I don't get any rendor errors. I have tested it on other GB+ files and it work's fine. Just for some reason this one file is causing issues.
(I'm essentially just sending file bytes from browser to browser and download on 'remote' browser for testing. Might be something about the file metadata that messes things up - idk, will update if I find anything out)
from save-file.
Hm. Can you try
require('save-file/src/to-blob')(thatBigFileData, 'abc')
and see if the error persists?
from save-file.
Tried it, didn't work, tested on another file and still fine.
The processing of files on my end is always the same for any file. No idea why it fails on this one file. All byte arrays are Int8Arrays.
I think it has to be on my end since no one else had this issue. The file is .mkv but other .mkv files worked just fine.
Thanks for the input
Edit: I plan on trying out other file writers as well since I'd rather not hold the data in chromes memory. Really limits file sizes. This one just seemed easy to test out. (I think I seen a lib that can stream to fs)
from save-file.
Can you try to just
require('to-array-buffer')(yourFileData)
and see if the error is still there?
Yes, stream writer for the purpose of huge files is def better solution.
Mb consider it here as well, as one of possible inputs.
from save-file.
Unfortunately, that did not fix it ;(
I did test out arraybuffer on other files and again, they still worked.
I tried waiting a couple seconds after the fileByteArray got saved in memory just in case It was possibly trying to download while data was still being set, that was not the case.
Haha if you're interested, I can maybe PM you the file (just a tv show). In any case, ill continue to try different things out and let you know.
Thanks
from save-file.
I can maybe PM you the file
Yes, that would be the best. Google drive / whatever will work. I don't have the fix, I hoped to figure out the code part that hangs, so that's why asked to try.
from save-file.
Good news lol.
It for sure is on my end. I decided to just simply do a quick read of the file using FileReader and then download the results from the arraybuffer. That happens to work. Which is odd because it really shouldn't be any different from what i'm doing (moving bytes across browsers and then downloading the bytes).
I'll have to make a comparison between the two and see what's different (byte arrays). Even if the contents of the array was somehow off, It should still write a file (File should just be corrupt - but I don't think this is the case either)?
from save-file.
It depends on what exactly data you're saving, that can be a to-array-buffer error.
from save-file.
Related Issues (12)
- Return saved data in callback? HOT 1
- An in-range update of is-browser is breaking the build 🚨 HOT 1
- typescript typing? HOT 2
- Module not found: Error: Can't resolve 'save-file' HOT 10
- How to call multiple files same time? HOT 4
- Readable stream resulting null output HOT 1
- save with callback not working to response HOT 2
- Error while importing save from save-file package HOT 1
- Release/Tag number
- Can't open file dialog with suggested filename
- Safari cannot navigate top frame to data URL
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from save-file.