browser-upload resource endpoint

URL: /browser-upload.<format>

The Browser-based Upload API provides a mechanism whereby an application can allow files to be uploaded directly to the TypePad backend from a user's browser. Since the file-upload abilities of browsers are constrained, this API provides a browser-friendly alternative to a direct upload ability in the Data API. To avoid the need for clients to handle this as a special case, this endpoint also allows the creation of non-file assets.

Request Format

A browser-based upload request is a POST request to the endpoint URL /browser-upload.json with the Content-Type multipart/form-data. The arguments to be submitted in the request body are as follows:

redirect_to
(Required) The URL to redirect to one the upload operation completes or fails, as described below.
target_url
(Required) The (root-relative, with no scheme or authority) path of the endpoint at which the new asset will be created. This must be an endpoint at which a POST with an Asset as the body is expected. To upload a photo asset into a group, this URL will be /groups/<id>/photo-assets.
asset
A JSON-encoded Asset object that includes metadata about the asset to be created.
file
(Required) The actual file data. This must be submitted by an input type="file" HTML element or some other compatible mechanism. This argument is optional; if omitted, the asset will not have an associated file. If the selected asset type requires a file, an error will be returned.

The file argument must be the last parameter submitted. This allows the server to verify that the other parameters are correct before accepting the (potentially large) payload.

An upload via this API is functionally equivalent to a POST request with an Asset as its body submitted to the given target_url.

Response Format

The response to an upload request will be an HTTP redirect to the URL given in the redirect_to query string argument. In the case where the upload was successful, the following query string arguments will be appended to the callback URL:

status
The response code 201, meaning "Created".
asset_url
A URL at which the created asset (in JSON format) can be found. A GET request to this URL will return an Asset object describing the created asset, including the URL at which the media payload and thumbnail images thereof can be retrieved.

In the case of a failure, the following query string arguments will be appended.

status
An HTTP error status code describing what went wrong. 401 will be returned if the provided OAuth parameters were incorrect.

Authentication

So that this endpoint may be used effectively as the target of a form submission in a browser, it expects its OAuth arguments to be provided in the query string rather than in the HTTP Authorization header as with a normal API endpoint.

Supported Methods

POST Submit an asset to a particular URL in the form of a multipart/form-data message with a file attachment.

Query String Arguments

oauth_nonce
(Required) The OAuth "nonce" parameter, as described in the OAuth specification.
oauth_timestamp
(Required) The OAuth "timestamp" parameter, as described in the OAuth specification.
oauth_consumer_key
(Required) The OAuth "consumer key" parameter, as described in the OAuth specification.
oauth_signature_method
(Required) The OAuth "signature method" parameter, as described in the OAuth specification.
oauth_version
The OAuth "version" parameter, as described in the OAuth specification.
oauth_token
(Required) The OAuth "token" parameter, as described in the OAuth specification.
oauth_signature
(Required) The OAuth "signature" parameter, as described in the OAuth specification.