-
-
Notifications
You must be signed in to change notification settings - Fork 173
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
Chunked file uploads #6421
Chunked file uploads #6421
Conversation
8102ad8
to
228b130
Compare
I've tried to upload a EXE file. Kirby 4.2.0 throws a error |
Also I realized that file is still remains when I cancel the upload. Should be deleted. But should be careful when file replacing. |
@afbora We cannot delete the tmp file on cancel. But we clean up the files with a garbage collection. |
f3e3800
to
f311c15
Compare
f311c15
to
1372287
Compare
Adding the "two-person review" label as I realized we need to be super careful about the security implications here. There's a lot that could go horribly wrong if we miss anything. I think we are heading in a great direction though 👍 |
@lukasbestle makes sense. And as written in the initial post, I think we should have a few review rounds as well. Now getting the concept right, later adding unit tests etc. before final review. |
@distantnative What if we upload to the temp folder, does it make sense? If upload successful, we can move the file to the model root, if not garbage collector take care. |
@afbora That's what we are doing here. Just not the system temp folder as that doesn't persist across requests. So the first parts aren't there anymore when the last chunk is received. |
Is it theoretically possible to add a config option that will limit the file size? |
I've found few issues, could you confirm that?
|
@afbora the PR currently is not functional as it's in the middle of implementing changes based on Lukas' feedback and some troubles I encountered (see our comments discussion). Sorry that you tried, but I think any upload fails currently that needs more than one chunk. |
@distantnative No problem. I'll test again after PR is ready. |
Good point. I think it would make sense to make this an option for the file blueprint. |
@lukasbestle @tobimori are you thinking of something different than the existing accept maxsize option? |
I didn't know there was an option already. Consider my request as solved 😀 |
Also forgot about |
@lukasbestle added some more validations – skipping MIME types (will still checked for the full file), but at least basic ones as allowed extensions. |
Works great for me. I couldn't see any issue 🎉 |
I think I have encountered an issue: Uploading a large file and canceling while it's uploading, it still shows up in the file list after a reload. |
Turns out: When one cancels the upload dialog, all running uploads still run and finish in the background. This is not new in this PR but a lot more visible/likely to happen with a different expectation by the user. |
@lukasbestle @afbora Added a way to abort ongoing upload requests. Could you please review the last commit and test it out? |
@distantnative Still works great for me 👍 |
Co-authored-by: Lukas Bestle <[email protected]>
81e51f2
to
56272f0
Compare
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.
Works great for me as well 👍
Description
Summary of changes
Api\Upload
classApi\Api::upload()
to make it more easily to read and testReasoning
Changelog
Features
upload_max_filesize
limit as they're uploaded in chunks. If you want to restrict the upload size, please use the file blueprintaccept
maxsize
option: https://getkirby.com/docs/reference/panel/blueprints/file#acceptEnhancements
uploadAsChunks
JS helper functionFixed
Refactored
Kirby\\Api\Upload
class to handle file uploads via the REST APIReady?
For review team