The parts are identified by a boundary string, and the final boundary string is followed by two hyphens.Įach part of the multipart request needs an additional Content-Type header: The body of the request is formatted as a multipart/related content type and contains exactly two parts. The media portion of the request must be less than the maximum file size specified for this method. Set to the total number of bytes in the request body. Set to multipart/related and include the boundary string you're using to identify the parts of the request. The top-level HTTP headers to use when making a multipart upload request include: POST userId/messages/send?uploadType=multipart To use multipart upload, make a POST or PUT request to the method's /upload URI and add the query parameter ![]() This is a good choice if the data you are sending is small enough to upload again in its entirety if the connection fails. If you have metadata that you want to send along with the data to upload, you can make a single multipart/related request. If the request succeeds, the server returns the HTTP 200 OK status code along with any metadata: HTTP/1.1 200 POST /upload/gmail/v1/users/ userId/messages/send?uploadType=media HTTP/1.1Īuthorization: Bearer your_auth_token Email Message data ![]() The following example shows the use of a simple upload request for the Not required if you are using chunked transfer encoding. Set to the number of bytes you are uploading. Set to one of the method's accepted upload media data types, specified in the API reference. The HTTP headers to use when making a simple upload request include: For example: POST userId/messages/send?uploadType=media The method's /upload URI and add the query parameter To use simple upload, make a POST or PUT request to This might be true if you plan to send metadata for this resource in a separate request, or if no metadata is supported or available. The file is small enough to upload again in its entirety if the connection fails.The most straightforward method for uploading a file is by making a simple upload request. POST /gmail/v1/users/ userId/messages/send You can use this URI when creating or updating metadata values. If the resource contains anyĭata fields, those fields are used to store metadata describing the uploadedįile. The standard resource URI, for the metadata. Use this URI whenĮxample: POST /upload/gmail/v1/users/ userId/messages/send Standard resource URI with an “/upload” prefix. In fact, methods that support media uploads have two URI endpoints: When you upload media, you use a special URI. This is a good strategy to use for most applications, since it also works for smaller files at the cost of one additional HTTP request per upload. ![]() With this method, you use a session initiating request, which optionally can include metadata. For reliable transfer, especially important with larger files. Resumable upload: uploadType=resumable.For quick transfer of smaller files and metadata transfers the file along with metadata that describes it, all in a single request. Multipart upload: uploadType=multipart.For quick transfer of smaller files, for example, 5 MB or less. Specify the method you are using with the uploadType request parameter. You can make upload requests in any of the following ways. Accepted media MIME types: The types of binary data you can store using this method.Maximum upload file size: The maximum amount of data you can store with this method.The specific characteristics of the data you can upload are specified on the reference page for any method that supports media uploads: The Gmail API allows you to upload certain types of binary data, or media. The Gmail API allows you to upload file data when creating or updating a draft or when inserting or sending a message.
0 Comments
Leave a Reply. |