-
Notifications
You must be signed in to change notification settings - Fork 36
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
Use base64 attribute for attachments #25
Conversation
Use base64 attribute for attachments
nice improvement, thanks! |
Just a heads up: we received at least one incoming webhook from Mandrill last week where the I'm currently contacting Mandrill support regarding this. Hopefully it was just a one-time fluke, I'd very much want to be able to rely on the stated API rather than making guesses based on the content type. I'll let you know. |
@lime hey, thanks for following this up. Hopefully Mandrill support have a good answer - it would not be great to have to factor in a fallback! Let us know what you find out ok? |
This is what Mandrill support responded:
So if I understand that correctly, we need to change the behaviour to assume all attachments and images are base64. I responded to Mandrill asking for confirmation that, indeed, even |
@lime Thanks! Yep, |
Getting your production code broken by a sudden API change is a surprisingly effective motivator. ;D |
Okay, word from Mandrill again:
However, when I tried it out myself on our servers, this is what the payload contained:
Maybe they reverted the change? I guess we'll again wait for even more clarification from Mandrill... |
Meanwhile, an emergency fix for the breakage would be to treat self['base64'].nil? || self['base64'] So If anyone really needs this now, I've pushed a branch with the above code. You can use it by changing your Gemfile to: gem 'mandrill-rails', github: 'lime/mandrill-rails', branch: 'base64-quickfix' However, I'm really hoping we'll get some clarity in this soon, so we can create a permanent fix (with working tests). |
Here's the latest and greatest:
Okay. I guess the good news is that What would be the best way to resolve this then? The quick fix above works, but is ugly and unclear. We could create a new Thoughts, @tardate? |
@lime thanks for the update, sorry took me a few days to follow-up. Seems like |
Sure, I plan to get it done tonight. :) |
I noticed that the Mandrill documentation lists a
base64
boolean attribute which can be used to determine whether the raw attachment content is encoded or not. I confirmed that this is indeed the case.This PR exposes a
base64
getter on theAttachment
class, and also uses it indecoded_content
in place of matching the content type against/^text/
.