Skip to content
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

Fix sending attachments less than 3MB #483

Conversation

mrashed-dev
Copy link
Contributor

Description

We were not encoding the attachments properly for attachments less than 3MB. They should be b64 encoded. Now it should handle it correctly.

License

I confirm that this contribution is made under the terms of the MIT license and that I have the authority necessary to make this contribution on behalf of its copyright owner.

@kraju3
Copy link
Contributor

kraju3 commented Aug 19, 2024

@mrashed-dev Thanks for raising this PR. I have an edge case:

What if the clients doesn't specify a file but instead specify the base64 encoded content (i.e If they are not using our utility function)

Copy link
Contributor

@atejada atejada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good 👍

@mrashed-dev
Copy link
Contributor Author

@kraju3 we have specified already in all the sending functions that it must be a file pointer:

# @param request_body [Hash] The values to create the message with.
    #   If you're attaching files, you must pass an array of [File] objects, or
    #   you can use {FileUtils::attach_file_request_builder} to build each object attach.

However, we can expand this function to be more flexible where we can accept a b64 encoded string, but only for attachments that total less than 3MB. Otherwise it has to be a file object because of how we stream files to the API.

@mrashed-dev
Copy link
Contributor Author

@kraju3 function comments updated along with code to support this operation:

# @param request_body [Hash] The values to create the message with.
    #   If you're attaching files, you must pass an array of [File] objects, or
    #   you can pass in base64 encoded strings if the total attachment size is less than 3mb.
    #   You can also use {FileUtils::attach_file_request_builder} to build each object attach.

@mrashed-dev mrashed-dev merged commit 905072d into main Aug 20, 2024
5 checks passed
@mrashed-dev mrashed-dev deleted the CUST-3040-v-3-ruby-sdk-attachments-are-corrupted-in-our-ruby-sdk-while-sending-a-message branch August 20, 2024 14:36
mrashed-dev added a commit that referenced this pull request Aug 20, 2024
# Changelog
* Fixed sending attachments less than 3MB (#483, #482)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants