You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
File upload in browser - use PUT if possible #4380
Using PUT has some advantages over the existing POST:
The PHP code will be trigger as soon as the first few kbs arrived th server.
In contrary in case of POST the web server will first receive the whole file and trigger the PHP code after the upload has been finished.
Why is this a better approach:
quota and other checks can be performed right in the beginning
follow up processing can benefit from stream e.g. push data to external file systems, encrypt on the fly (?)
From my understanding this is why WebDAV uses PUT for file upload as well.
Next advantage: Once we switch to a PUT-based approach, we can implement file chunking, too. This means that for all practical purposes (with the unfortunate exceptions of the infamous IE 8 and 9), we do not have to deal with stupid PHP upload limitations. This alone will save us quite some headaches in the future.
Will apps that require the whole file behave properly? Like encryption or versioning for example.
From my understanding all file operations within ownCloud work on streams - if not we need to change this.
We cannot expect to have enough server RAM to process e.g. 10 user requests on a 4 GB file all in RAM.
I suggest we keep this ticket as a subticket of #12353.
Implementing PUT is already a challenging task, especially in regards to cross-browser compatibility. So it makes sense to have this implemented in its own PR.
Interesting, the blueimp uploader would POST to this URL with the IE iframe fallback:
192.168.56.102 - - [17/Dec/2015:18:17:06 +0100] "POST /owncloud/remote.php/webdav/modern.IE.1024x768.jpg?_method=PUT HTTP/1.1" 501 247 "http://192.168.56.1/owncloud/index.php/apps/files/" "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)"
This means that in theory instead of keeping "ajax/upload.php" we could simply write a Sabre plugin that processes this POST and internally plugs with the PUT logic. 😄
Activity
danimo commentedon Aug 9, 2013
Next advantage: Once we switch to a PUT-based approach, we can implement file chunking, too. This means that for all practical purposes (with the unfortunate exceptions of the infamous IE 8 and 9), we do not have to deal with stupid PHP upload limitations. This alone will save us quite some headaches in the future.
icewind1991 commentedon Aug 9, 2013
No need for that, there isn't a restriction on the size of PUT uploads in the first place
danimo commentedon Aug 9, 2013
@icewind1991 good point. still, chunks could be useful for resuming big downloads.
butonic commentedon Aug 9, 2013
There is an in depth description at http://stackoverflow.com/questions/12005790/how-to-receive-a-file-via-http-put-with-php
Don't know if we have to manually cut the headers from the body. Will take a look along with the client side changes.
DeepDiver1975 commentedon Aug 9, 2013
@butonic webdav/sabredav already uses PUT for file upload - here is the code:
https://github.com/fruux/sabre-dav/blob/master/lib/Sabre/DAV/CorePlugin.php#L421
blizzz commentedon Aug 12, 2013
Will apps that require the whole file behave properly? Like encryption or versioning for example.
DeepDiver1975 commentedon Aug 12, 2013
From my understanding all file operations within ownCloud work on streams - if not we need to change this.
We cannot expect to have enough server RAM to process e.g. 10 user requests on a 4 GB file all in RAM.
@icewind1991 @schiesbn
bartv2 commentedon Aug 18, 2013
Also now we have auth via session maybe we can use the webdav interface to do uploading of files?
LukasReschke commentedon Oct 30, 2014
Adding to technical debt. Would make very much sense. @MorrisJobke Does something similiar in his music app for reading files.
MorrisJobke commentedon Oct 30, 2014
I just use get because I don't need PUT nowadays, but we should enforce using our own APIs and the WebDAV is the most stable of them ;)
DeepDiver1975 commentedon Mar 2, 2015
this will be implemented once we move over to use webdav in the files apps #12353
PVince81 commentedon Jun 9, 2015
I suggest we keep this ticket as a subticket of #12353.
Implementing PUT is already a challenging task, especially in regards to cross-browser compatibility. So it makes sense to have this implemented in its own PR.
13 remaining items
PVince81 commentedon Dec 17, 2015
Interesting, the blueimp uploader would POST to this URL with the IE iframe fallback:
This means that in theory instead of keeping "ajax/upload.php" we could simply write a Sabre plugin that processes this POST and internally plugs with the PUT logic. 😄
PVince81 commentedon Feb 12, 2016
Still needs a bit more work for the PR #21237, moving to 9.1
MTRichards commentedon Apr 1, 2016
Estimation: 1 week
PVince81 commentedon Jun 21, 2016
Someone raised a ticket for PUT chunking. Since we didn't have a dedicated ticket, let's use this one #25181
PVince81 commentedon Sep 8, 2016
Hmm, but when overwriting a file we are using POST on collection with "Add-Member" here https://tools.ietf.org/html/rfc5995#page-5 here https://github.com/owncloud/core/blob/master/apps/dav/lib/Connector/Sabre/FilesPlugin.php#L440.
This is used when the conflict dialog appears and the user wants to keep old files, so we use "Add-Member" to suggest a name for the server. The server then append "(2)", "(3)" or whatever depending on existing files.
Drawback is that we still use POST and would suffer from limitations.
Reopening to reconsider this.
Also this approach is not compatible with new chunking, so might still need a client-side only approach that looks like this:
PVince81 commentedon Sep 9, 2016
Fix for autorename is here: #26078
This removes POST completely for uploads.
lock commentedon Aug 3, 2019
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.