Giter VIP home page Giter VIP logo

Comments (11)

Hassall avatar Hassall commented on May 29, 2024 1

@dy

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.

dy avatar dy commented on May 29, 2024 1

Ok I see. Bumped to-array-buffer, try the latest release 2.2.1. Should be fixed.

from save-file.

dy avatar dy commented on May 29, 2024

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.

Hassall avatar Hassall commented on May 29, 2024

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.

dy avatar dy commented on May 29, 2024

Hm. Can you try

require('save-file/src/to-blob')(thatBigFileData, 'abc')

and see if the error persists?

from save-file.

Hassall avatar Hassall commented on May 29, 2024

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.

dy avatar dy commented on May 29, 2024

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.

Hassall avatar Hassall commented on May 29, 2024

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.

dy avatar dy commented on May 29, 2024

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.

Hassall avatar Hassall commented on May 29, 2024

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.

dy avatar dy commented on May 29, 2024

It depends on what exactly data you're saving, that can be a to-array-buffer error.

from save-file.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.