The FileInfo Class

FileInfo is provided by the google.appengine.ext.blobstore module.

If you use the Blobstore API to upload files to Google Cloud Storage, your upload handler receives the resulting metadata such as the filename, creation date, and content type, and the complete GCS object name including path. Your upload handler extracts this metadata into FileInfo objects using the parse_file_info() function.

Unlike BlobInfo metadata FileInfo metadata is not persisted to datastore. (There is no blob key either, but you can create one later if needed by calling create_gs_key.) You must save the gs_object_name yourself in your upload handler or this data will be lost. The other metadata for the object in GCS is stored in GCS automatically, so you don't need to save that in your upload handler.

  1. Introduction
  2. Instance properties:


When a blob is uploaded to Google Cloud Storage using the Blobstore API, certain metadata is created, such as the filename, creation time, file size, content type, and most importantly, the full GCS filename that you need to retrieve the file from GCS. Blobstore passes this metadata to the upload handler in the headers of the MIME part for the file. The upload handler can parse this information into a FileInfo object without calling the datastore using the parse_file_info() function. If you're using the webapp or webapp2 application framework, you can use the BlobstoreUploadHandler for more convenient parsing of this information.

Instance Properties

A FileInfo instance has the following properties:

The MIME type of the Blobstore object, as provided by the client in the Content-Type HTTP header during upload. A string.
The date and time the blob was saved to GCS. A datetime value.
The filename of blob written to GCS, as provided by the client that uploaded the file. A string.
The size of the file.
The md5 hash value of the blob uploaded to GCS.
The full name of the file written to Google Cloud Storage (including path) or None if the file was not uploaded to Google Cloud Storage.