user3064538
user3064538

Reputation:

What is the format of a folder ID in Google Drive?

My question is similar to What is format of Google Drive's FileID ? I need to find out whether new File has been uploaded to my drive or not using API's but I want to know the format of a folder ID in Google Drive, the one that appears in the URL bar when you open a folder in your Google drive, the thing after https://drive.google.com/drive/u/0/folders/<this part>.

Upvotes: 0

Views: 1469

Answers (2)

Linda Lawton - DaImTo
Linda Lawton - DaImTo

Reputation: 116986

Google Drive folder id doesn't have a specific guaranteed format. This (apparent format which really isn't a format) has changed in the past and may change again.

Trying to create any kind of local verification of this will be futile.

The best option would be to do a Files: get and test if you get a response. This will work better as it will also verify that the user has access to the file as well as testing that its a valid file id format.

Any (regex) attempt to verify the file id wouldn't really verify it as its not going to test if the user has access.

Upvotes: 2

user3064538
user3064538

Reputation:

A folder ID starts with a 1 followed by 32 base-64 encoded digits, except unlike base64 the + is replaced by - and / is replaced by _. You can use the following regex:

/^1[A-Za-z0-9-_]{32}$/

Upvotes: 0

Related Questions