File path to a google Drive folder

I have a google drive folder set up. One of my python functions needs the filepath, not the file itself. How can I get that? I feel like it’s super simple and I’m missing it in the documentation.

Also. if I want to access a file (let’s say 123.txt), but I don’t know the python ID name (because I’m passing it a string of an uploaded file from the user, how can I reference it from the google drive folder

What I have:

from anvil.google.drive import app_files
gdriveFolder=app_files.tempuserfiles

filename is a string

gdriveFolder.get(filename) is getting the file, not the path there.

I think you’ll need to save the file to disk and then pass the filename of that newly saved file. See these docs: Anvil Docs | Files, Media Objects and Binary Data

See the second code block in this section of the Drive docs. Does that answer your question?

Thanks so much, that helped! I got it working!

1 Like

Glad to hear that! (Could you mark my reply as the Solution so that it’s easy for others to see this question is resolved?)

sure, but please help me with OSError: [Errno 30] Read-only file system " .chroma"

1 Like

3 posts were split to a new topic: Loading Google sheets into tensorflow