10mib request limit being hit with call to sendgrid api - Is there another way to make the sendgrid api call with attachments?

691 views
Skip to first unread message

Rob Curtis

unread,
Feb 28, 2017, 10:22:11 AM2/28/17
to Google App Engine
Hi, 

We have an application where a list attachments must be sent in a single mail to 1 address. 
Sendgrid has 30MB limit on attachment size, but Appengine has a 10MB limit on request size.
The sendgrid api requires base64 encoding of the files, which results in the request size being larger than 10MB (if the files are large)

  1. Is there an alternative method for attaching files to a mail in sendgrid?
  2. Is there means to change the request size in AppEngine or use some mechanism for calling the sendgrid API?
Thanks
Rob

Nick (Cloud Platform Support)

unread,
Mar 1, 2017, 2:10:42 PM3/1/17
to Google App Engine
Hey Rob,

The attachment size limit for the Mail API can't be relaxed. Sendgrid's limit is larger, at 30MB, but I'm unsure what you mean in your post. Do you mean to say that files, when b64 encoded, will be larger than 30 MB (the sendgrid limit)?

One way you can get around this entirely (and solutions like this are becoming more and more popular as cloud storage becomes cheaper and cheaper) is to store the items in Cloud Storage and send an email to your user with a Signed URL for downloading it, or add their email to the ACL on the object / bucket and serve them a simple URL like storage.googleapis.com/<bucket>/<object> (read more on such URL's here).

Let me know if you have any further questions and I'll be happy to assist.

Cheers,

Nick
Cloud Platform Community Support

Rob Curtis

unread,
Mar 5, 2017, 11:07:29 PM3/5/17
to Google App Engine
Hi Nick,

Thanks for you response. Sorry I missed this.

What I meant is that the google urlfetch limit is 10MB limit on request size, and because we have send the entire message (to sendgrid) as json with B64 encoded files, we can only send a maximum of 10MB (which is the limit imposted by GAE). 

I wanted to know if there is any method to relax the 10MB limit imposed by GAE?

Thanks
Rob

Nick (Cloud Platform Support)

unread,
Mar 8, 2017, 3:24:20 PM3/8/17
to Google App Engine
Hey Rob, 

Thanks for clarifying. The 10 MB UrlFetch request size limit is a hard limit on the service. In this case, I'd recommend using Cloud Storage to serve the files you want to send, as mentioned in my last reply. 

Cheers,

Nick
Cloud Platform Community

P K

unread,
Mar 9, 2017, 2:09:28 PM3/9/17
to Google App Engine
This will not solve your immediate problem but you might want to star this feature request: https://issuetracker.google.com/issues/35897109

As I have said many times, Google needs to provide a mail service as part of GCP. A main reason is that this way it can serve attachments to/from GCS. This cannot be done from SendGrid and others.

PK
Reply all
Reply to author
Forward
0 new messages