cloudFile API

The cloudFile (a.k.a. fileLink) API first appeared in Thunderbird 60. It allows to create a provider to store large attachments in the cloud instead of attaching them directly to the message.

From Thunderbird 68.2.1 (Thunderbird 71 beta), an extension can choose to receive data for upload as a File object rather than as an ArrayBuffer. You should specify which you want as the default may change in a future version.

The DropBox Uploader sample extension uses this API.

Manifest file properties

[cloud_file]

(object, optional)

management_url

(string)

A page for configuring accounts, to be displayed in the preferences UI. Note: Within this UI only a limited subset of the WebExtension APIs is available: cloudFile, extension, i18n, runtime, storage, test.

name

(string)

Name of the cloud file service.

[browser_style]

(boolean, optional)

– [Added in TB 90]

Enable browser styles in the management_url page. See the MDN documentation on browser styles for more information.

[data_format]

(string, optional)

– [Added in TB 71, backported to TB 68.2.1]

Determines the format of the data argument in onFileUpload. Support for ArrayBuffer will be removed in Thunderbird 102.

Supported values:

ArrayBuffer

File

[new_account_url]

(string, optional) Deprecated.

This property was never used.

[service_url]

(string, optional)

URL to the web page of the cloud file service.

Note

A manifest entry named cloud_file is required to use messenger.cloudFile.*.

Functions

getAccount(accountId)

Retrieve information about a single cloud file account.

Parameters

accountId

(string)

Unique identifier of the account.

Return type (Promise)

getAllAccounts()

Retrieve all cloud file accounts for the current add-on.

Return type (Promise)

array of CloudFileAccount

updateAccount(accountId, updateProperties)

Update a cloud file account.

Parameters

accountId

(string)

Unique identifier of the account.

updateProperties

(object)

[configured]

(boolean, optional)

If true, the account is configured and ready to use. Only configured accounts are offered to the user.

[managementUrl]

(string, optional)

A page for configuring accounts, to be displayed in the preferences UI.

[spaceRemaining]

(integer, optional)

The amount of remaining space on the cloud provider, in bytes. Set to -1 if unsupported.

[spaceUsed]

(integer, optional)

The amount of space already used on the cloud provider, in bytes. Set to -1 if unsupported.

[uploadSizeLimit]

(integer, optional)

The maximum size in bytes for a single file to upload. Set to -1 if unlimited.

Return type (Promise)

Events

onFileUpload

Fired when a file should be uploaded to the cloud file provider.

Parameters for onFileUpload.addListener(listener)

listener(account, fileInfo, tab)

A function that will be called when this event occurs.

Parameters passed to the listener function

account

The account used for the file upload.

fileInfo

The file to upload.

tab

(Tab)

– [Added in TB 91]

The tab where the upload was initiated. Currently only available for the message composer.

Expected return value of the listener function

object

[aborted]

(boolean, optional)

Set this to true if the file upload was aborted by the user and an onFileUploadAbort event has been received. No error message will be shown to the user.

[templateInfo]

(CloudFileTemplateInfo, optional)

– [Added in TB 96, backported to TB 91.4.1]

Information to override the default values used in the cloud file message template.

[url]

(string, optional)

The URL where the uploaded file can be accessed.

onFileUploadAbort

Parameters for onFileUploadAbort.addListener(listener)

listener(account, fileId, tab)

A function that will be called when this event occurs.

Parameters passed to the listener function

account

The account used for the file upload.

fileId

(integer)

An identifier for this file.

tab

(Tab)

– [Added in TB 91]

The tab where the upload was initiated. Currently only available for the message composer.

onFileDeleted

Fired when a previously uploaded file should be deleted.

Parameters for onFileDeleted.addListener(listener)

listener(account, fileId, tab)

A function that will be called when this event occurs.

Parameters passed to the listener function

account

The account used for the file upload.

fileId

(integer)

An identifier for this file.

tab

(Tab)

– [Added in TB 91]

The tab where the upload was initiated. Currently only available for the message composer.

onAccountAdded

Fired when a cloud file account of this add-on was created.

Parameters for onAccountAdded.addListener(listener)

listener(account)

A function that will be called when this event occurs.

Parameters passed to the listener function

account

The created account.

onAccountDeleted

Fired when a cloud file account of this add-on was deleted.

Parameters for onAccountDeleted.addListener(listener)

listener(accountId)

A function that will be called when this event occurs.

Parameters passed to the listener function

accountId

(string)

The id of the removed account.

Types

CloudFile

Information about a cloud file.

object

data

id

(integer)

An identifier for this file.

name

(string)

Filename of the file to be transferred.

CloudFileAccount

Information about a cloud file account.

object

configured

(boolean)

If true, the account is configured and ready to use. Only configured accounts are offered to the user.

id

(string)

Unique identifier of the account.

managementUrl

(string)

A page for configuring accounts, to be displayed in the preferences UI.

name

(string)

A user-friendly name for this account.

[spaceRemaining]

(integer, optional)

The amount of remaining space on the cloud provider, in bytes. Set to -1 if unsupported.

[spaceUsed]

(integer, optional)

The amount of space already used on the cloud provider, in bytes. Set to -1 if unsupported.

[uploadSizeLimit]

(integer, optional)

The maximum size in bytes for a single file to upload. Set to -1 if unlimited.

CloudFileTemplateInfo

Defines information to be used in the cloud file entry added to the message.

object

[service_icon]

(string, optional)

A URL pointing to an icon to represent the used cloud file service. Defaults to the icon of the provider add-on.

[service_name]

(string, optional)

A name to represent the used cloud file service. Defaults to the associated cloud file account name.

[service_url]

(string, optional)

An URL to the web page of the used cloud file service. Used to attach a link to the service_name. Defaults to the service_url manifest entry. Set to an empty string in order to not create a link.