Opened 10 months ago
Last modified 10 months ago
#21497 new enhancement
Make uploads on XML-RPC resumable
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | XML-RPC | Version: | |
| Severity: | minor | Keywords: | has-patch |
| Cc: |
Description
In order to play nicely with unreliable internet connections (ie, mobile, conference wifi) it would be nice to be able to resume uploads over the XML-RPC API.
Attachments (3)
Change History (5)
The new patch tidies up the code a bit, and removes some unnecessary checks and error messages.
To give an overview of what this patch does, it adds 5 new parameters to the data struct:
- resume: flags if this is a resumable upload or not.
- filesize: the intended size of the file being uploaded.
- path: the path on the server that the file is being uploaded to. This is required for the second chunk onwards.
- location: the byte location in the file that the current chunk is being written to. At the moment, the code only supports appending to the file, so the only valid location is at the end, but it could be modified to write to anywhere in the file.
- url: The public url of the uploaded file, as returned by wp_upload_bits(). This is required for the final chunk, when it's given to wp_insert_attachment().
While the upload is incomplete, the return struct has a path element, instead of an id element, used to identify the file being uploaded.
A few things that I haven't decided yet:
- I'm not sure that path is the correct unique identifier to use, as it could be a security problem. Writing to /tmp isn't really an option, it won't work on cluster setups.
- How to handle the potential to overwrite another site's files in MS.
- If we should be pre-allocating the entire space in the wp_upload_bits() call, so it can do sanity checking on the file size immediately.
Note: See
TracTickets for help on using
tickets.

Example usage of the tester:
php resumable-test.php -u test -p test -f ~/Pictures/P1120772.JPG -h http://localhost/wordpress/xmlrpc.php -s 2097152