I'm currently trying to store all gmail emails attachement, witch are encoded in base64url (https://developers.google.com/gmail/api/v1/reference/users/messages/attachments).
gmail.users.messages.attachments.get({
'auth': auth,
'userId': 'me',
'id': 'attachementId',
"messageId": 'messageId'
}, function(err, response, seg) {
if (err) {
//
} else {
var base64_attachement = response.data.replace(/-/g, '+').replace(/_/g, '/').replace(/ /g, '+');
var buffer = new Buffer(base64_attachement, "base64");
var attachementDecode = buffer.toString();
}
});
But when i store the message in a file or in my S3 and I try to read it (with the good format) I can't see anything, and images editors as gimp say thats the image is corrupted. What am I doing wrong ? I'm really lost how can I decode a google attachement in base64url format ?