-
Notifications
You must be signed in to change notification settings - Fork 19
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
Fix: Upload Endpoints #565
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #565 +/- ##
==========================================
+ Coverage 94.60% 94.67% +0.07%
==========================================
Files 89 89
Lines 4724 4770 +46
Branches 648 652 +4
==========================================
+ Hits 4469 4516 +47
+ Misses 233 232 -1
Partials 22 22 ☔ View full report in Codecov by Sentry. |
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. Would it make sense to add unit tests on the behavior specific to MultipartUploadedFile
and RawUploadedFile
?
@philogicae this should fix the file upload issue you reported. |
pyaleph/src/aleph/web/controllers/storage.py Line 272 in 885c59c
Based on aiohttp docs post method looks like it's made for MultipartForm:
@hoh Maybe should i add a check and use read() for RawUploadedFile ? |
…-data instead of request.post()
We should use multipart method instead of post You might have noticed a big warning in the example above. The general issue is that aiohttp.web.BaseRequest.post() reads the whole payload in memory, resulting in possible OOM errors. To avoid this, for multipart uploads, you should use aiohttp.web.BaseRequest.multipart() which returns a multipart reader: => |
I did a quick general review because I don't know the business code very well and some of them are more questions/suggestions, don't hesitate if you have questions :) |
@Psycojoker I did some updates:
The main thing I didn't change is that we're still reading and writing the file to a temporary file first to avoid launching the workflow if the file is too large and we need to calculate the hash early for safety check. I wasn't using the manager correctly, that should be fixed now. |
Hugo suggested that we could do a call at some point if you want me to explain some of my comments. |
a4e3828
to
406c4ae
Compare
9703a10
to
526de08
Compare
We did a pair programming session and that should be good on my side regard good python practices. Lyam told me he needed to do one last test with the frontend before confirming it's good. |
@hoh @Psycojoker Just finish my last test, everything looks working as intended, I would say ready for merge |
Issue
Issue Description:
The current file upload endpoint reads the entire file before checking if it exceeds the maximum allowed size. The size limits are 25 MB for unauthenticated uploads (MAX_UNAUTHENTICATED_UPLOAD_FILE_SIZE) and 1000 MB for authenticated uploads (MAX_UPLOAD_FILE_SIZE).
Proposed Solutions: