Enable media uploads using the WP REST API from WP.com
In r178976-wpcom and r178977-wpcom I added a way to upload media from the WP.com WP REST API, using a request like this:
curl -v -X POST -F 'file=@/path/to/file.jpg` -F 'description=test description' -H 'Authorization: Bearer YOUR_TOKEN' https://public-api.wordpress.com/wp/v2/sites/nylen.io::jp/media
This will not actually work on the Jetpack side yet, though. The request is successfully authenticated and passed to the WP REST API upload endpoint, but in order to finish the job, it will be necessary to decode the _files body parameter and make it look and behave like the results of the $_FILES PHP array.
This _files parameter has the following structure (if it exists for a given request):
[
{
"name": "file.jpg",
"type": "image/jpeg",
"contents": // base64-encoded file contents,
"size": // file size in bytes,
},
...
]
Here is the code that will use the resulting data: https://core.trac.wordpress.org/browser/tags/4.9.7/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php#L671
This issue has been marked as stale. This happened because:
- It has been inactive in the past 6 months.
- It hasn’t been labeled `[Pri] Blocker`, `[Pri] High`.
No further action is needed. But it's worth checking if this ticket has clear reproduction steps and it is still reproducible. Feel free to close this issue if you think it's not valid anymore — if you do, please add a brief explanation.
This was fixed some time ago via D18560-code.