Hide
Apps Script

Class File

File

Deprecated. The DocsList service was deprecated on December 11, 2014. To work with files in Google Drive, use the Drive service instead.

This class contains methods to get information about the file and modify its contents.

 

 // This example logs the file type of the first file
 var file = DocsList.getAllFiles()[0];
 Logger.log(file.getFileType());
 

Methods

MethodReturn typeBrief description
getAs(contentType)BlobReturn the data inside this object as a blob converted to the specified content type.
getBlob()BlobReturn the data inside this object as a blob.

Detailed documentation

getAs(contentType)

Return the data inside this object as a blob converted to the specified content type. This method adds the appropriate extension to the filename — for example, "myfile.pdf". However, it assumes that the part of the filename that follows the last period (if any) is an existing extension that should be replaced. Consequently, "ChristmasList.12.25.2014" will become "ChristmasList.12.25.pdf".

Parameters

NameTypeDescription
contentTypeStringthe MIME type to convert to. For most blobs, 'application/pdf' is the only valid option. For images in BMP, GIF, JPEG, or PNG format, any of 'image/bmp', 'image/gif', 'image/jpeg', or 'image/png' are also valid.

Return

Blob — the data as a blob


getBlob()

Return the data inside this object as a blob.

Return

Blob — the data as a blob

Deprecated methods