Create files

To create a file that contains no metadata or content, use the files.create method with no parameters. The file is given a kind of drive.file, an id, a name of "Untitled", and a mimeType of application/octet-stream. The uploadType is marked as required but defaults to media, so you don't actually have to supply it.

For more information about Drive file limits, see File and folder limits.

Create metadata-only files

Metadata-only files contain no content. Metadata is data (such as name, mimeType, and createdTime) that describes the file. Fields like name are user-agnostic and appear the same for each user, whereas fields such as viewedByMeTime contain user-specific values.

One example of a metadata-only file is a folder with the MIME type application/vnd.google-apps.folder. For more information, see Create and populate folders. Another example is a shortcut that points to another file on Drive with the MIME type application/vnd.google-apps.shortcut. For more information, see Create a shortcut to a Drive file.

Upload thumbnails

Drive automatically generates thumbnails for many common file types, such as Google Docs, Sheets, and Slides. Thumbnails help the user to better identify Drive files.

For file types that Drive can't generate a standard thumbnail for, you can provide a thumbnail image generated by your application. During file creation or update, upload a thumbnail by setting the contentHints.thumbnail field on the files resource.

Specifically:

  • Set the contentHints.thumbnail.image field to the URL and filename safe base64-encoded image (see RFC 4648 section 5).
  • Set the contentHints.thumbnail.mimeType field to the appropriate MIME type for the thumbnail.

If Drive can generate a thumbnail from the file, it uses the automatically generated one and ignores any you might have uploaded. If it can't generate a thumbnail, it uses the one you provide.

Thumbnails should adhere to these rules:

  • Can be uploaded in PNG, GIF, or JPG formats.
  • The recommended width is 1600 pixels.
  • The minimum width is 220 pixels.
  • The maximum file size is 2 MB.
  • They should be updated by your application with each save.

For more information, see the files resource.

Here are a few next steps you might try: