2017년 4월 7일 금요일

A question about AI2 and Google Image handling


In AI2 using the device camera I take a picture and save it to Google drive using Web component. In the ”GotText” block of the web component I can extract the “downloadUrl” and the “title” of the image and save these data in tinyDB on the device. Later I can retrieve the “downloadUrl” of the image I want from the TinyDB and using the web component download the image and save it to the SD card of the device. This works perfectly. If I wait a few hours an try to download an image I get error 401, In response to that the app starts the Authentication process using Refresh token, get a new Access token and download the image successfully. However, if I wait longer time, say, 24 hours and then try to download the image I get error 403 “Forbidden”. Even if I start the authentication process and get a new Access token I still get error 403. In this situation there is no way for me to use the “downloadUrl” I saved in the tinyDB to retrieve the image. However, if I list the contents of the Google drive and chose the same image, it will be downloaded. But the “downloadUrl” is now different from the one I saved in the first place. So, I am wondering if there is a time limit to the “downloadUrl” one gets when saving an image or video to Google drive. If so, is there any other way than listing the Google drive files and choosing a file to remember the image details and download them when necessary?
--
the downloadURL is a short lived information, see the documentation https://developers.google.com/drive/v2/reference/files#resource
Short lived download URL for the file. This is only populated for files with content stored in Drive.

did you try webContentLink?

alternatively store the image in a public directory on your Google Drive, then you can read it later using its id also without authorization

this snippet updates the metadata of the image to store it a public folder

to get the folder id, create a new folder in your Google Drive and Share it to "Anybody with link" and get the folder id from the Share dialog.

--
I will test this. When it comes to webContentLink, Is it possible to programatically create a directory, mark it as public, and mark the files saved there as public?

probably yes, please take a look at the documentation
if the directory is public, all files inside are automatically public, too

PS: please keep the discussion in the forum. thank you.

--
I apologize if the response i send to you went to your private e-mail. It was not intentional. I use the only button on the forum that allows one to give a response.
I have gone through the documents you referenced and have been able to firstly download images from a shared directory without Authentication and secondly to create a new folder on the Google drive. What I am struggling with now, and seem not to be able to do, is to make the folder public. I have tried to change the shared variable using the meta data manipulation with no luck, see attached screen shot. I have also tried to set visibility to Public with no luck. I do not get any errors but the folder is still private.
I see in the documents that shared is not marked as writable. Maybe that is the reason, but then how can I set the directory to public.
Would appreciate any suggestions.
--

댓글 없음:

댓글 쓰기