Coder Social home page Coder Social logo

Comments (10)

sunli829 avatar sunli829 commented on April 28, 2024 1

Actually, I am preparing to implement Read for Upload, which will probably be completed tomorrow. Because this depends on the new parser.๐Ÿ˜

from async-graphql.

nicolaiunrein avatar nicolaiunrein commented on April 28, 2024 1

Sorry didnโ€™t realise. Thatโ€™ll awesome!

from async-graphql.

sunli829 avatar sunli829 commented on April 28, 2024 1

This is very difficult to achieve, and I don't think GraphlQL can do it. ๐Ÿ™‚

from async-graphql.

sunli829 avatar sunli829 commented on April 28, 2024 1

So I was reading about it, I think it would be possible but only when you have one file. In theory we could get a stream of the body directly from the TCP stream after we read the query and the map of files.

You are right, it can indeed be optimized when only one file is uploaded, I will think about it. ๐Ÿ™‚

from async-graphql.

sunli829 avatar sunli829 commented on April 28, 2024

I'm also leaning towards the first option, and I want to remove the dependency on the actix-multipart to make it more compatible with other web servers. The actix-multipart input is Stream<Item=Bytes>, but I want it to be an AsyncRead. I searched existing crates and didn't have a working asynchronous multipart parser, so I probably had to write a new one.

Then add a function like Schema::query_from_request<R: AsyncRead>(&self, content_type: &str, body: R), should be easier to use.

from async-graphql.

nicolaiunrein avatar nicolaiunrein commented on April 28, 2024

Sounds good. ๐Ÿ‘

from async-graphql.

sunli829 avatar sunli829 commented on April 28, 2024

I ended up choosing the first option because the second option had some problems with the order of requests.

from async-graphql.

Sytten avatar Sytten commented on April 28, 2024

@sunli829 I was reading the code and as far as I understand the file needs to be completely uploaded (either in memory or in temp) before it is returned as an async stream. This is not great for large files where you might want to stream the data without buffering it. Unsure if it is doable though.

from async-graphql.

Sytten avatar Sytten commented on April 28, 2024

So I was reading about it, I think it would be possible but only when you have one file. In theory we could get a stream of the body directly from the TCP stream after we read the query and the map of files.

But if you upload more than one file you need to buffer for sure to the disk. Still for a lot of cases it would be a worthwhile optimisation. Just unsure if you want to support it @sunli829

My use case is that users are uploading large files to the server and since tempfile is used I can't just move them where I want, I have to copy them so for a bit of time I have 2x the disk usage which is annoying. An alternative that would work for me would be to have a named file, so maybe that would be a better approach (just another feature flag).

from async-graphql.

nicolaiunrein avatar nicolaiunrein commented on April 28, 2024

Iโ€˜m reading this thread since I originally opened the issue. I currently do not use this library anymore. Just wondering @Sytten canโ€˜t you just persist the tempfile? In general I think it would be good if one could get a reference to an AsyncRead of the uploaded content.

from async-graphql.

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.