问题
I'm working on project which can access all the pictures in g-mail.I've tried the G-mail API using node which can fetch all required attachments.But that requires to download the whole image.I can access the attachment id and message id using the API.Is there any way to generate the url of attachment (to view) so that i can provide a link to the required image from my project.
回答1:
I actually found this related issue, Issue #134, and you may want to try the suggested solution.
You may fetch email attachments using this:
https://mail.google.com/mail/u/0/?ui=2&ik={ik_value}&view=att&th={message_id}&attid=0.{atachment_index}&disp=safe&zw
wherein,
attachmment_index
is just the index of the attachment. If there are 3 attachments and you want to get the 3rd file, the index value will be3
. This URL is a 302 header that acts like a link shortener for the download file. Opening this link will lead you to the attachment data
var ik = gmail.tracker.ik;
var id = gmail.get.email_id();
var aid = "1"; // gets the first attachment
var url = "https://mail.google.com/mail/u/0/?ui=2&ik=" + ik + "&view=att&th=" + id + "&attid=0." + aid + "&disp=safe&zw";
console.log(url);
来源:https://stackoverflow.com/questions/42166981/generate-gmail-attachment-url-to-view