Get a google drive file ID for an image after it is taken through the app?

Hi All,

I am trying to find a way to automatically collect the google file ID of an image after I have taken it in appsheet. Is there a simple way to do this at all?

I have found the link below, which I believe will do exactly what im trying to achieve, but I couldn't find the google app script to make it work?

Any ideas? Thanks again!

0 12 3,036
12 REPLIES 12

You can't do that from Appsheet, you'd need an external service like App Script. 

Also you mentioned a link, but you didn't provide any link.

What i'm after is exactly what is shown in the example app, but I cant find the appscript code at the link or in the associated sheets file.

Sorry, I don't know how to get an attached GAS from a sample app.

Should be easy enough to write the script though:

  1. onChange()
  2. if file-id column is blank
  3. get files from GDrive folder
  4. iterate through files, does filename match?
  5. grab matched file's id and insert into file-id column

Easiest way is to

  1. add table as collection of files
  2. add virtual column in target table as URL
  3. App formula: "https://drive.google.com/file/d/" & SELECT(collection of files_name[_ID],CONTAINS([Path],[referenced_ID]))

 

  • "collection of files_name" is the name of the folder the file or image is saved
  • "_ID" extracts the unique link ID of the file: for example https://docs.google.com/spreadsheets/d/[_ID]/
    (automatically created as column by adding table as collection of files) 
  • [Path] is the path created by uploading your file/image in your app or simply
  • [referenced_ID] is part of the generated name of the uploaded file

THIS!  This is the answer to the question.  Much more elegant and simple than going into apps script (or other non-solutions that just point to the "File" field type.)

Thank you

I went back here to thank you. It's a pretty nice solution. 

I'm pretty sure you can even input folders , copy every file containing them inside the collection of files folder, and returns the right OG file path in the right OG folder using a child table and an automatizer like Zenphi or Zapier.

Not saying I tried tough. But if anyone faces this use case where he want to push this solution even further, this is what you can try.

(welp, people can also directly retrieve the file ID without collections of table using the same automatizer at the end, it would be strange if no one ever tried)

I have a something set up exactly like this - a virtual folder pointing to a folder in Google Drive (a collection of files). It has worked well, but with one caveat: The file cannot be shared - The "Share" icon isn't available. One can download the file, and then share, but the URL generated doesn't allow sharing. Now this is in Google WorkSpace, where we only want people with access to AppSheet to access the linked files--and share them. But boy it would make things a lot easier if the link allowed direct sharing. 

Any suggestions?

I just tested my set up, and when I click the action to "open URL" it takes me to the linked document (in my case a PDF) and shows the "Share" button.  Which does allow any user with edit access to the file to share further.  

However, I have another field where I use the "file" field type (not the URL field type), and when I click to view that file I see what you are describing (Just the download and print buttons).  

I'd start by checking the field type on your field.  If it's "File" that might be the issue.  The "File" field type, is nice because there is a lot of built in functionality around uploading and viewing the docs, but it is not a direct link to the file. 

I think this solution is unique because it allows the user clickable access to the direct Google Drive link (using the URL field type).  Where as other answers I've found say suggest using the File type and external services.  

I get what you are saying, but the action, auto generated by the system for the "a collection of files" folder, is "Open File". I created an "Open URL" action, but can't figure out how to point to the file's own location.

That's where @harrihundert answer above comes in.  

I think they explain the steps very concisely, but the idea is ...

Make a virtual column with the field type as "URL",

Then make the app formula as described in step 3. 

This will give you the direct link to your drive file based on the contents of your "collection of files", and allow you to leverage the open URL actions (since the field type is URL)

I would recommend making sure that AppSheet is generating a unique name for the file.

You should be able to use AppSheet to trigger an AppScript to return the value of the object ID if you use the getFilesByName() method.

Landan_QREW_0-1701789614941.png

 

Top Labels in this Space