browser-upload resource endpoint
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.
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:
- (Required) The URL to redirect to one the upload operation completes or fails, as described below.
- (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.
- A JSON-encoded Asset object that includes metadata about the asset to be created.
- (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.
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:
- The response code 201, meaning "Created".
- 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.
- An HTTP error status code describing what went wrong. 401 will be returned if the provided OAuth parameters were incorrect.
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.
|POST||Submit an asset to a particular URL in the form of a multipart/form-data message with a file attachment.|
Query String Arguments
- (Required) The OAuth "nonce" parameter, as described in the OAuth specification.
- (Required) The OAuth "timestamp" parameter, as described in the OAuth specification.
- (Required) The OAuth "consumer key" parameter, as described in the OAuth specification.
- (Required) The OAuth "signature method" parameter, as described in the OAuth specification.
- The OAuth "version" parameter, as described in the OAuth specification.
- (Required) The OAuth "token" parameter, as described in the OAuth specification.
- (Required) The OAuth "signature" parameter, as described in the OAuth specification.