如何将大邮件上传到Gmail [英] How to upload large messages to Gmail

查看:80
本文介绍了如何将大邮件上传到Gmail的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Gmail API导入邮件,并且我注意到 接下来的问题.目前,我正在对此网址执行POST:

I am using the Gmail API to import messages, and I have noticed the following issue. Currently I am doing a POST to this url:

https://www.googleapis.com/gmail/v1/users/me/messages?uploadType = multipart

设置了以下http标头:

The following http headers are set:

Content-Length: <n>
Content-Type: application/json

发布的json数据如下:

The posted json data looks like this:

{
"labelIds": ["Label_154"],
"raw": "RnJvbTo..."
}

(原始数据当然是一个更大的基于64位编码的RFC-822消息)

(the raw data of course is a much larger based64 encoded RFC-822 message)

这有效,但是对于一个客户,他们在http 413错误 一些消息,我认为这意味着消息太大.我有 尚未发现实际消息有多大.我看过一些文件 那说我应该改用这个网址:

This works but for one customer they are getting http 413 errors on some messages, which I believe means that the message is too large. I have not yet found out how big the actual message is. I have seen some documentation that says I should use this url instead:

https://www.googleapis.com/upload/gmail/v1/users/me/messages?uploadType = multipart

但是随后API抱怨不支持json,我应该使用 内容类型消息/rfc822.我希望继续使用json和 原始编码数据,因此我不必对代码进行实质性更改. 您能告诉我此方法的实际消息大小限制是多少吗? 有没有办法可以使用其他端点达到35mb的最大限制?

But then the API complains that json is not supported, I should use Content-Type message/rfc822. I was hoping to continue to use json and raw encoded data so I don't have to make substantial changes to my code. Can you tell me what the actual message size limit is for this method, and is there a way I can go up to the full 35mb limit using a different endpoint?

推荐答案

对于大于几MB的内容,最好使用媒体(/上载)路径.是的,仅接受电子邮件消息(message/rfc822有效负载).希望更改代码应该不会太困难.由于您已经必须具有base64(message/rfc822)才能发送到现有的JSON端点,因此您可以停止对消息的base64进行处理,然后将其包装在JSON中.

For anything larger than a few MB it's best to use the media (/upload) path. Yes, that only accepts email messages (message/rfc822 payload). Hopefully shouldn't be too difficult to change code. Since you already have to have a base64(message/rfc822) to send to the existing JSON endpoint, you can just stop doing the base64 of the message and then wrapping it in JSON.

如果您使用/upload端点,则可以一直发送邮件,直到最大gmail邮件大小(25MB,在经过base64编码后,最大可能为34MB).

If you use the /upload endpoint you'll be able to send messages all the way up to the max gmail message size (25MB, which after base64 encoding may be as much as 34MB).

这篇关于如何将大邮件上传到Gmail的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆