iOS - download attachment from Gmail using messageId and attachmentId

主宰稳场 提交于 2019-12-06 05:54:41

You have the Ids mixed up a bit.

GTLQueryGmail *query2 = [GTLQueryGmail queryForUsersMessagesAttachmentsGet];
        query2.id=attachmentId;
        query2.messageId=mailID;

The data you get in your response is Base64-encoded and has been made URL safe by replacing all "+" with "-", and all "/" with "_".

Simply convert it back to regular Base64-data and decode it! Try this in your Developer Tools (press F12):

atob("SGV5IE5pbGVzaCEgSSBob3BlIHlvdSB3aWxsIGdldCBpdCB0byB3b3JrIHNvb24h".replace(/\-/g, '+').replace(/\_/g, '/'));

Do the same steps in your code and you will have your data in its original format.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!