--- layout: docs title: File ---

Summary

File model represents a File object served by the Nylas Platform API. For more information about Files on the Nylas Platform, read the Files API Documentation

Attributes

filename: AttributeString The display name of the file. Queryable.

size: AttributeNumber The size of the file, in bytes.

contentType: AttributeString The content type of the file (ex: image/png)

contentId: AttributeString If this file is an inline attachment, contentId is a string that matches a cid: found in the HTML body of a Message.

This class also inherits attributes from Model

Instance Methods

displayName()

Files can have empty names, or no name. displayName returns the file's name if one is present, and falls back to appropriate default name based on the contentType. It will always return a non-empty string.

displayExtension()

Returns
Return Values

Returns the file extension that should be used for this file. Note that asking for the displayExtension is more accurate than trying to read the extension directly off the filename. The returned extension may be based on contentType and is always lowercase.

Returns the extension without the leading '.' (ex: 'png', 'pdf')