Luk Aron
Luk Aron

Reputation: 1415

Checking if google drive file is a Google Docs, Sheets, and Slides?

How do we know if a google drive file is a Google Docs, Sheets, and Slides?

Any patterns?

{
                        "kind": "drive#file",
                        "id": "xxxxxxxxxxxxxxxxxxxxxxxx",
                        "etag": "\"xxxxxxxxxxxxxxxxxxxxx\"",
                        "selfLink": "https://www.googleapis.com/drive/v2/files/xxxxxxxxxxxxxx",
                        "alternateLink": "https://docs.google.com/document/d/xxxxxxxxxxxxx/edit?usp=drivesdk",
                        "embedLink": "https://docs.google.com/document/d/xxxxxxxxxxxxx/preview?ouid=xxxxxxxxxxxxxxx",
                        "iconLink": "https://drive-thirdparty.googleusercontent.com/16/type/application/vnd.google-apps.document",
                        "thumbnailLink": "https://docs.google.com/feeds/vt?gd=true&id=xxxxxxxxxxxxxxxxx&v=1&s=AMedNxxxxxxxxxxpdmctLve-fDRQL6N9iGoAJ-aE&sz=s220",
                        "title": "Title",
                        "mimeType": "application/vnd.google-apps.document",
                        "labels": ⊕{5 items},
                        "copyRequiresWriterPermission": false,
                        "createdDate": "2021-06-02T03:33:25.303Z",
                        "modifiedDate": "2021-06-02T03:34:04.112Z",
                        "markedViewedByMeDate": "1970-01-01T00:00:00.000Z",
                        "version": "17",
                        "parents": ⊕[1 item],
                        "exportLinks": ⊕{8 items},
                        "userPermission": ⊕{7 items},
                        "quotaBytesUsed": "0",
                        "ownerNames": ⊕[1 item],
                        "owners": ⊕[1 item],
                        "lastModifyingUserName": "myname",
                        "lastModifyingUser": ⊕{6 items},
                        "capabilities": ⊕{2 items},
                        "editable": false,
                        "copyable": true,
                        "writersCanShare": true,
                        "shared": true,
                        "explicitlyTrashed": false,
                        "appDataContents": false,
                        "spaces": ⊖[
                            "drive"
                        ]}

Seems mimeType give some hints but not always

application/vnd.google-apps.document should be a google doc

Upvotes: 3

Views: 582

Answers (2)

Linda Lawton - DaImTo
Linda Lawton - DaImTo

Reputation: 116968

The standard way to tell any file type is by its media type or mime type.

If you check the response that you have shown you will see

"mimeType": "application/vnd.google-apps.document",

This will tell you that it is a google-apps type of file. Then you can check the documentation for the google mime types to find which type it is.

enter image description here

Upvotes: 2

Luk Aron
Luk Aron

Reputation: 1415

"mimeType": "application/vnd.google-apps.spreadsheet"\
"mimeType": "application/vnd.google-apps.presentation"\
"mimeType": "application/vnd.google-apps.document",

are the answer

Upvotes: 0

Related Questions