2

I would like to avoid downloading a Google Doc image if it already exists locally, that is, we have previously downloaded the image some weeks before.

These images may have been inserted by dragging from the desktop so there is no external source URI and they do not appear to be stored in the user's Drive or Photos account, so I do not think there is an ID.

The only reference to the image in the JSON representation of the Google Doc is a temporary URI valid for 30 minutes.

So, if this is a dead end, is there a way to sniff the name of the image from the temporary URI? Or is there another method?

I'm using the Go client, Google Docs Api V1 and Google Drive Api V3.

David Smith
  • 892
  • 1
  • 6
  • 16
  • 1
    About `downloading a Google Doc via the Google Docs API`, JSON data is retrieved from Google Document using the method of "documents.get" in Google Docs API. Is my understanding correct? By the way, in the current stage, it seems that the images on Google Document are not managed by the original filename. So in my case, in order to distinguish each image in Google Document, I use the image title and description. By them, I check whether an image has already been used in the Google Document. I think that this might be a current workaround. I apologize for this. – Tanaike Nov 01 '20 at 23:21
  • 1
    @Tanaike Hello, yes that is correct, I'm using "documents.get". When you say, "I use the image title and description" are you referring to the properties an author would have to set manually in the Google Doc? BTW I must thank you for your public postings and open source efforts; they have been a great help in deciphering Google's APIs. – David Smith Nov 01 '20 at 23:50
  • 1
    Thank you for replying. And thank you for stopping at my blog. In the current stage, when the image is put to Google Document and the Google Document is often edited, it is required to set the title and/or description as the identifier. Or, if the Google Document is not often edited and you have known about each image at that time, I think that a script might be able to be used. Unfortunately, in the current stage, I think that there might not be the clear method for directly achieving your issue. I apologize for this. – Tanaike Nov 02 '20 at 00:14
  • @Tanaikee Thank you, I wonder if I could download just a small chunk of the file and then examine the response header? Or, even the file header? Is there a way to only download a small part of the file? – David Smith Nov 02 '20 at 00:24
  • Thank you for replying. I have to apologize for my poor English skill. Unfortunately, I cannot understand what you want to do from `I wonder if I could download just a small chunk of the file and then examine the response header? Or, even the file header?`. Can I ask you about the detail of your goal? – Tanaike Nov 02 '20 at 00:26
  • @Tanaikee To put it another way, is there a way to download an image's first n number of bytes with the Google Drive API? Then I could examine the embedded data. – David Smith Nov 02 '20 at 00:32
  • 1
    Thank you for replying. About the partial download, are these threads useful? https://stackoverflow.com/q/59763613/7108653 https://stackoverflow.com/q/60181888/7108653 – Tanaike Nov 02 '20 at 00:36
  • @Tanaikee Those links are very useful, thank you, I will do some reading. – David Smith Nov 02 '20 at 00:40
  • Is using partial downloads a useful workaround for your situation? If that's the case, would you consider posting an answer explaining this? Also, would you consider sharing the relevant parts of the code you're using to download the images? In this case, I would like to think about a workaround. – Iamblichus Nov 02 '20 at 13:48

0 Answers0