/upload/. This means that the upload endpoint is available at:
- http://yoursite.com/upload/ (home)
- http://yoursite.com/some-blog-post/upload/ (a blog post)
- http://yoursite.com/events/some-event/upload/ (a custom post type)
- http://yousite.com/members/username/upload/ (a BuddyPress profile)
- and so on, on any WordPress url
The upload endpoint only supports a $_POST request and returns a 404, not found error on a $_GET request, as when requested by a browser.
Needless to say, the upload endpoint will only work (as will rtMedia) when pretty permalinks are enabled.
The upload endpoint POST method accepts the following $_POST fields, along with the $_FILES array. What follows is a brief description. Look at the Upload Object for more details.
- mode (optional) The possible values and their meaning for the upload endpoint.
- file_upload (default): Files are being uploaded from the users’ hard drive
- link_input: A url needs to be imported
- and any custom mode that has been registered via custom hooks and filters
The context in which the upload needs to be processed. If not provided, the endpoint will figure out the current context depending on the current WordPress url. On a single post type, the context will be set to the name of the post type (for eg, post, page, event, etc).
On a BuddyPress page, the context will be the current component. A custom context can also be hooked in. Although, this parameter is optional, it must be specified if a context_id is specified.
This is the unique id of the context. If not specified, the current context_id is assumed. On a single post type, the post ID becomes the context_id. On a BuddyPress component, the component id is used instead. For eg, on a user profile, the context is the user_id. On a group, the context_id is the group id and so on. If a context_id is specified, a context must be specified, as well.
The user id of the author. If not provided, the currently logged in user is assumed.
privacy (optional) The privacy for the media. If not supplied, defaults to the current default privacy of the user, then to the site, and failing which, to 0 (public).
custom_fields (optional) The meta data as an array of key-value pairs. These are stored in the rtm_media_meta table.
The taxonomy for the media. These can be categories, tags or any custom taxonomy. As taxonomies in a multisite environment are stored in different tables for each site, this feature is currently not supported in multisite environments.
The id of the album in which the upload should be placed. This could be any post type, or the implicit rt-media-album post type. If not provided, the global default ‘Wall Posts’ album will be assumed.
If the files are already on the server (say via FTP), but just need to be added to rtMedia, a fake file array is passed into this parameter.
The text that will be stored as the title.
The text/html that will be stored as the description.
A valid nonce for the upload. For an API request, you have to generate nonce via a previous nonce* call.
A nonce request has not been factored into the code yet. So, cross domain API requests are not supported as of now.