Giter Site home page Giter Site logo

Comments (3)

jpfluger avatar jpfluger commented on April 23, 2024 1

You know.... I slept on this. Multer already has options.onFileUploadData, which emits the event for data. You have the chunks here but these chunks aren't saved to file. When I added the option.inMemory last night, it also includes a new file.buffer property. Within onFileUploadData(file, data), file.buffer would contain the data chunk plus any preceding chunks, whereas the data param would be that single chunk. Hope that helps.

from multer.

jpfluger avatar jpfluger commented on April 23, 2024

Multer's files are the completely assembled file (all chunks combined).

Multer uses busboy for parsing html multipart data. In busboy, an event is not emitted for chunks of files. An event is emitted for having uploaded the entire file. See busboy code, lines 189 - 205. According to the node docs, FileStream does support the data event, which will return the chunks you need.

You could post an issue on busboy and see if they might emit the chunk event but beyond that I'm not sure what to suggest. At the multer level, we could take the emitted chunk and write it to file. Is this all you'd need? If so, I think there's hope... but this is where my knowledge quickly thins: you'll need a way to figure out if the incoming data started in the middle of the file upload or if it was just beginning. (chuck mgmt process?) If you can step through the logic to implement this, maybe someone reading could take a stab at it?

Sorry, I have no real good answers for you. But maybe someone else will have more insight or know of other resources to do this.

from multer.

jpfluger avatar jpfluger commented on April 23, 2024

The onFileUpload* functions now include req and res. That doesn't give you minute control over file chunks but is a step closer. Now you can get a socket.io instance attached to your req or res session and report back to the client upload progress. Again, it's not allowing for chunked memory management on the server but will create a more responsive app for the client.

from multer.

Related Issues (20)

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.