-
Notifications
You must be signed in to change notification settings - Fork 130
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
Allow custom filename when adding an attachment #496
Allow custom filename when adding an attachment #496
Conversation
@@ -92,8 +92,8 @@ def self.handle_message_payload(request_body) | |||
# Build the request to attach a file to a message/draft object. | |||
# @param file_path [String] The path to the file to attach. | |||
# @return [Hash] The request that will attach the file to the message/draft | |||
def self.attach_file_request_builder(file_path) | |||
filename = File.basename(file_path) | |||
def self.attach_file_request_builder(file_path, filename = nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively, it could also be named parameter: filename: nil
.
@SubashPradhan could you please tell me what do you think about this PR, is there a chance of merging it? |
@loomchild Thanks for looking into this, while sending an attachment, you can configure the custom Have you tried the above approach, example of custom
|
No. I don't want to load the entire attachment to memory. It also won't work for files > 3M per your documentation, since they require special multi-part request to Nylas API and simple Base64 embedded in JSON won't do. That's why I want to use That's why I am suggesting a simple improvement in your SDK, but if you are not interested, feel free to drop it. |
I see, thanks for the explanation, we should be good to merge the doc comment is added. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for contributing 🎉
Sure, thanks for approving 🙂. Looking forward to the next release. |
Unfortunately it doesn't work for attachments > 3MB (unfortunately I didn't test it earlier). |
Description
When adding an attachment to an email, the filename that will be sent is determined by the provided file path. This is problematic when using
Tempfile
because part of the path will be random. I propose accepting an optionalfilename
parameter inFileUtils.attach_file_request_builder
.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.