You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In version 3, any plans to update attachments to support InputStream instead of File? Our system creates PDF on the fly, never saving to file system. Works in your version 2...need this to upgrade.
I've checked the code and it looks like I just need to add a new method that accepts InputStream as a parameter and then calls setContent which doesn't sound really helpful. I haven't found any methods that accept plain Files in current version. Has I missed something?
When I look at Attachments.Builder, I see that it calls toByteArray at some point.
/**
* Creates a newly allocated byte array. Its size is the current
* size of this output stream and the valid contents of the buffer
* have been copied into it.
*
* @return the current contents of this output stream, as a byte array.
* @see java.io.ByteArrayOutputStream#size()
*/
public synchronized byte[] toByteArray() {
return Arrays.copyOf(buf, count);
}
Does then the solution scale? Are there better options for sending attachemnts? If there are 10 request at sime time, each sending 10mb attachment file, then 100mb of RAM will be used?
Activity
thinkingserious commentedon Aug 30, 2016
Hello @ChickenSniper,
Well, now we do :)
I'll add this to our backlog so we can add this to the Mail Helper.
Meanwhile, the
setContentfunction only needs the content to be base64 encoded. Looks like this function will get you there.dmitraver commentedon Oct 12, 2016
Hi!
Is it still relevant? I can help with this if its still needed.
ChickenSniper commentedon Oct 12, 2016
@dmitraver It would definitely be helpful...I'm using this library in my scala application, so streams are very important to us for performance...
thinkingserious commentedon Oct 12, 2016
@dmitraver,
Thanks for offering to help!
Please take a moment to sign our CLA so that I can merge your solution when ready: https://github.com/sendgrid/sendgrid-java/blob/master/CONTRIBUTING.md#cla
dmitraver commentedon Oct 13, 2016
@thinkingserious cool, then I will sign a CLA and make a PR in a couple of days
dmitraver commentedon Oct 14, 2016
I've checked the code and it looks like I just need to add a new method that accepts InputStream as a parameter and then calls setContent which doesn't sound really helpful. I haven't found any methods that accept plain Files in current version. Has I missed something?
thinkingserious commentedon Oct 15, 2016
@dmitraver,
Here is how it was done previously:
sendgrid-java/src/main/java/com/sendgrid/SendGrid.java
Line 120 in b64988f
I hope that helps.
Fix sendgrid#134. Adds an attachment builder class that supports pass…
Fix sendgrid#134. Adds an attachment builder class that supports pass…
Fix sendgrid#134. Adds an attachment builder class that supports pass…
Fix sendgrid#134. Adds an attachment builder class that supports pass…
jmayday commentedon Nov 23, 2018
When I look at Attachments.Builder, I see that it calls toByteArray at some point.
Does then the solution scale? Are there better options for sending attachemnts? If there are 10 request at sime time, each sending 10mb attachment file, then 100mb of RAM will be used?