I am fetching Gmail Attachment through Gmail API using the get_user_message_attachment
method , but the data it sends is in Base64 encoded form. I want to get the attachment's downloadable URL, which I can store and send to the frontend of my application. Is it possible to get the URL of the attachment in some way? I do not want to convert the Base64 string to a file on my server and then upload it somewhere and send that upload's link to the front-end.
@gmail_service = Google::Apis::GmailV1::GmailService.new
#authorization stuff is done and then I fetch the attachment which is received as a Google::Apis::GmailV1::MessagePartBody response
resp = @gmail_service.get_user_message_attachment("[email protected]", message_id, attachment_id)
# resp.data contains the base64 encoded string
I want the attachment as a downloadable URL, so that I don't have to do the manual file conversion and uploading stuff.
The message.get method returns a Message object
This object contains the body of the message base64 encoded.
If you want a downloadable url I suggest that you convert the Base64 string to a file on your server and then upload it somewhere and send that upload's link to the front-end.
There is no other option this is the data the API returns.