如何使用MediaUploader类发送大约15 MB的附件

时间:2015-09-03 09:06:00

标签: gmail-api

有人可以帮我理解如何在发送附件大约15 MB的电子邮件时使用MediaUploader课程吗?

目前,我可以发送包含最高950 KB但不超过该附件的附件的电子邮件。

使用的网址是 - url:https://www.googleapis.com/gmail/v1/users/user@xyz.com/messages/send

我的代码看起来像这样,

.......

DataReader* reader = NewManagedInMemoryDataReader(&MsgData);
DataReader* encoder = codec->NewManagedEncodingReader(reader, NULL, &status);
encoder->ReadToString(/*RawMessage.length()*/kint64max, &EncodedPayload);

Message* message = Message::New();
message->set_raw(EncodedPayload);

OAuth2Credential* credential_ = GetUserCredential(email);

std::unique_ptr<UsersResource_MessagesResource_SendMethod> method(service_->get_users().get_messages().NewSendMethod                                                                                (credential_, email.c_str(), message, "", NULL));

method->ExecuteAndParseResponse(message)

...

以下是出错时的日志提取,

I0904 12:06:42.522728 17834 client_service.cc:100] Prepared url:https://www.googleapis.com/gmail/v1/users/user%40xyz.com/messages/send
I0904 12:06:42.524838 17834 http_request.cc:1083] Adding builtin headers
I0904 12:06:42.524919 17834 http_request.cc:285] set_state_code=2 on 0xf7212d88
I0904 12:06:42.524960 17834 http_request.cc:609] DoExecute using transport:Curl
I0904 12:06:42.525488 17834 curl_http_transport.cc:335] Setting timeout to ms=1234567
I0904 12:06:44.138020 17834 curl_http_transport.cc:385] Got http_code=413 for POST url=https://www.googleapis.com/gmail/v1/users/user%40xyz.com/messages/send
I0904 12:06:44.150180 17834 http_transport.cc:223] No configured error handler for http_code=413
I0904 12:06:44.150480 17834 http_request.cc:768] Finished 0xf7212d88
I0904 12:06:44.150554 17834 http_request.cc:285] set_state_code=3 on 0xf7212d88
I0904 12:06:44.150590 17834 http_request.cc:320] Signal 0xf7212d88

我们如何使用可恢复上传? 我们必须使用此方法“GmailService :: UsersResource :: DraftsResource :: NewSendMethod(client :: AuthorizationCredential * credential ,const StringPiece&amp; user_id,const Draft * metadata ,const StringPiece&amp; _media_content_type_,client :: DataReader * _media_content_reader_)“?

谢谢, Harshal

0 个答案:

没有答案