-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
File upload #655
File upload #655
Conversation
# Conflicts: # codegen/config/config.go # handler/graphql.go # handler/graphql_test.go
I just had myself the need for this. right on time! thanks. |
This is exactly what I need! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, sorry its taken so long to do a review of this.
Overall it looks good, test coverage and docs 😍
@vektah Hi Adam! Thank you very much for considering and reviewing the PR. I will resolve the comments. Thanks :) |
…e decoding and function signature, improve documentation)
@vektah Hi Adam, sorry it took me so long to implement the changes.
There were two things that lead me to do this change:
So for what I see this would be the Pros and Cons of this approach (using []byte, instead of multipart.File):
Cons:
Please let me know if you think that using a multipart.File or any other approach would be better. |
Yeah this is where it gets tricky :) Two things I don't like about this approach:
Obviously we cant pass the same handle to two concurrent resolvers, they would be each getting different parts of the file, even if they both seeked to zero. I think there are a few approaches:
I'm not sure how much you want to bite off in this PR, maybe 1 or 2 are the best bets right now. |
@vektah ok, I will improve it a bit more in the following days |
@vektah I implemented the suggested changes, combining approaches 1 and 2. If a file is used in just one path, then the request form file is used. There is no need to store it in another form, as it is not going to be read by multiple readers. If a file is used in more than one path, it will be read by multiple readers, so it is handled differently depending on the request size. Thanks for the previous comment, let me know if you see other improvements that could be made. |
@vektah I made an improvement so that if the request is smaller than the uploadMaxMemory, it uses a to shared bytes reader. Let me know if you have any comments or if see other improvements that could be made. |
I think you arrived at a great implementation. Nice work. |
@vektah Thanks Adam! |
Awesome @hantonelli, thank you! |
This PR adds the feature of uploading files.
I have:
Fixes #342
Fixes #656