Opened 8 years ago
Closed 8 years ago
#40343 closed enhancement (wontfix)
REST API - set attachment upload directory on request
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.8 |
Component: | REST API | Keywords: | needs-unit-tests |
Focuses: | rest-api | Cc: |
Description
When using the Rest API to migrate content from a third-party system to WordPress it is useful to be able to specify the upload directory for systems that have month/day upload structures enabled. This can prevent a larger legacy system from dumping a large amount of files into the upload directory for the current month.
In my use case I would have ended up with 200'000+ files in the 2017/03 directory.
I propose adding another header to the /media endpoint that can be used to set the upload directory via a YYYY/MM date. This can then be passed to the wp_handle_sideload
function.
I have attached a proof of concept, which likely needs validation
Attachments (2)
Change History (4)
#2
@
8 years ago
- Keywords dev-feedback 2nd-opinion removed
- Milestone Awaiting Review deleted
- Resolution set to wontfix
- Status changed from new to closed
Thanks for filing this ticket! While I understand the desire for this, WordPress always stores images based on the file creation time. The only exception to this is when uploading images attached to an existing post, in which case it uses the date of that post instead. Apart from this, the creation date for a file cannot be set anywhere.
While there is a use-case for setting this manually, this is something that belongs in an import-specific API, and isn't something for the general-purpose API. This matches existing behaviour with things like GUIDs and modification times, which cannot be set manually.
Thanks for the ticket and patch anyway!
Reads a time header to pass to wp_handle_sideload. Probably needs validation / errorhandling.