Make WordPress Core

Opened 21 months ago

Last modified 21 months ago

#21497 new enhancement

Make uploads on XML-RPC resumable

Reported by: pento Owned by:
Milestone: Awaiting Review Priority: normal
Severity: minor Version:
Component: XML-RPC Keywords: has-patch
Focuses: Cc:


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)

resumable-upload.diff (4.5 KB) - added by pento 21 months ago.
resumable-test.php (1.8 KB) - added by pento 21 months ago.
resumable-upload.2.diff (5.1 KB) - added by pento 21 months ago.

Download all attachments as: .zip

Change History (5)

pento21 months ago

pento21 months ago

comment:1 pento21 months ago

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

pento21 months ago

comment:2 pento21 months ago

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.