Skip to content

attachments - Support for InputStream? #134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ChickenSniper opened this issue Aug 30, 2016 · 8 comments
Closed

attachments - Support for InputStream? #134

ChickenSniper opened this issue Aug 30, 2016 · 8 comments
Labels
status: work in progress Twilio or the community is in the process of implementing type: community enhancement feature request not on Twilio's roadmap

Comments

@ChickenSniper
Copy link

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.

Thanks!

@thinkingserious thinkingserious added type: question question directed at the library status: help wanted requesting help from the community labels Aug 30, 2016
@thinkingserious
Copy link
Contributor

Hello @ChickenSniper,

Well, now we do :)

I'll add this to our backlog so we can add this to the Mail Helper.

Meanwhile, the setContent function only needs the content to be base64 encoded. Looks like this function will get you there.

@dmitraver
Copy link
Contributor

Hi!

Is it still relevant? I can help with this if its still needed.

@ChickenSniper
Copy link
Author

@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 thinkingserious added type: community enhancement feature request not on Twilio's roadmap status: work in progress Twilio or the community is in the process of implementing and removed status: help wanted requesting help from the community type: question question directed at the library labels Oct 12, 2016
@thinkingserious
Copy link
Contributor

@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
Copy link
Contributor

@thinkingserious cool, then I will sign a CLA and make a PR in a couple of days

@dmitraver
Copy link
Contributor

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
Copy link
Contributor

@dmitraver,

Here is how it was done previously:

if (email.getAttachments().size() > 0) {

I hope that helps.

dmitraver added a commit to dmitraver/sendgrid-java that referenced this issue Oct 18, 2016
RichardCSantana-zz pushed a commit to RichardCSantana-zz/sendgrid-java that referenced this issue Apr 12, 2017
RichardCSantana-zz pushed a commit to RichardCSantana-zz/sendgrid-java that referenced this issue Apr 17, 2017
RichardCSantana-zz pushed a commit to RichardCSantana-zz/sendgrid-java that referenced this issue Apr 17, 2017
@jmayday
Copy link

jmayday commented Nov 23, 2018

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: work in progress Twilio or the community is in the process of implementing type: community enhancement feature request not on Twilio's roadmap
Projects
None yet
Development

No branches or pull requests

4 participants