0
votes

Does anyone has any example of Gmail Api resumable uploading(for attachments). I succeeded using the main upload for attachments up to 5 MB but I would like to send attachments over 30 MB.I cant use gmail SDK to everything needs to be in Rest Any suggestions?

2

2 Answers

0
votes

Gmail API Resumable Upload

The steps for using resumable upload include:

Step 1: Start a resumable session

To initiate a resumable upload, make a POST or PUT request to the method's /upload URI and add the query parameter uploadType=resumable, for example:

POST https://www.googleapis.com/upload/gmail/v1/users/userId/messages/send?uploadType=resumable

For this initiating request, the body is either empty or it contains the metadata only; you'll transfer the actual contents of the file you want to upload in subsequent requests.

Step 2: Save the resumable session URI

If the session initiation request succeeds, the API server responds with a 200 OK HTTP status code. In addition, it provides a Location header that specifies your resumable session URI. The Location header, shown in the example below, includes an upload_id query parameter portion that gives the unique upload ID to use for this session.

Example: Resumable session initiation response

Here is the response to the request in Step 1:

HTTP/1.1 200 OK
Location: https://www.googleapis.com/upload/gmail/v1/users/userId/messages/send?uploadType=resumable&upload_id=xa298sd_sdlkj2
Content-Length: 0

Step 3: Upload the file

To upload the file, send a PUT request to the upload URI that you obtained in the previous step. The format of the upload request is:

PUT session_uri

Full code implementation sample is in the docs.

0
votes

you need upload PUT method

but not binary body, only use multipart form body