Skip to content

attachments - Support for InputStream? #134

Closed

Description

@ChickenSniper

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!

Activity

  1. added
    type: question
    status: help wanted
    on Aug 30, 2016
  2. thinkingserious commented on Aug 30, 2016

    @thinkingserious
    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.

  3. dmitraver commented on Oct 12, 2016

    @dmitraver
    Contributor

    Hi!

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

  4. ChickenSniper commented on Oct 12, 2016

    @ChickenSniper
    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...

  5. added
    type: community enhancement
    status: work in progress
    and removed
    status: help wanted
    type: question
    on Oct 12, 2016
  6. thinkingserious commented on Oct 12, 2016

    @thinkingserious
    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

  7. dmitraver commented on Oct 13, 2016

    @dmitraver
    Contributor

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

  8. dmitraver commented on Oct 14, 2016

    @dmitraver
    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?

  9. thinkingserious commented on Oct 15, 2016

    @thinkingserious
    Contributor

    @dmitraver,

    Here is how it was done previously:

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

    I hope that helps.

  10. added a commit that references this issue on Oct 18, 2016
    c04e25f
  11. added 3 commits that reference this issue on Apr 12, 2017
    99b945a
    24a1074
    21757f1
  12. jmayday commented on Nov 23, 2018

    @jmayday

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: work in progresstype: community enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions