cloudFile API
The cloudFile (a.k.a. fileLink) API allows to create a provider to store large attachments in the cloud instead of attaching them directly to the message.
Manifest file properties
cloud_file
management_url
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. The id of the to be configured cloud file account can be retrieved via new URL(location.href).searchParams.get(‘accountId’);.
name
Name of the cloud file service.
browser_style
Enable browser styles in the management_url page. See the MDN documentation on browser styles for more information.
data_format
This property is no longer used. The only supported data format for the data argument in onFileUpload is File.
new_account_url
This property was never used.
reuse_uploads
If a previously uploaded cloud file attachment is reused at a later time in a different message, Thunderbird may use the already known url and templateInfo values without triggering the registered onFileUpload listener again. Setting this option to false will always trigger the registered listener, providing the already known values through the relatedFileInfo parameter of the onFileUpload event, to let the provider decide how to handle these cases.
service_url
This property is no longer used. The service_url property of the CloudFileTemplateInfo object returned by the onFileUpload event can be used to add a Learn more about link to the footer of the cloud file attachment element.
Permissions
Functions
getAccount(accountId)
– [Added in TB 64]
Retrieve information about a single cloud file account. Returns undefined, if the requested account does not exist.
getAllAccounts()
– [Added in TB 64]
Retrieve all cloud file accounts for the current add-on.
updateAccount(accountId, updateProperties)
– [Added in TB 64]
Update a cloud file account. Returns undefined, if the requested account does not exist.
Parameters
accountId
Unique identifier of the account.
updateProperties
configured
If true, the account is configured and ready to use. Only configured accounts are offered to the user.
managementUrl
A page for configuring accounts, to be displayed in the preferences UI.
spaceRemaining
The amount of remaining space on the cloud provider, in bytes. Set to -1 if unsupported.
spaceUsed
The amount of space already used on the cloud provider, in bytes. Set to -1 if unsupported.
uploadSizeLimit
The maximum size in bytes for a single file to upload. Set to -1 if unlimited.
Events
onAccountAdded
– [Added in TB 64]
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
– [Added in TB 64]
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
The id of the removed account.
onFileDeleted
– [Added in TB 64]
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
An identifier for this file.
tab
onFileRename
– [Added in TB 97]
Fired when a previously uploaded file should be renamed.
Parameters for onFileRename.addListener(listener)
listener(account, fileId, newName, 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
An identifier for the file which should be renamed.
newName
The new name of the file.
tab
Expected return value of the listener function
cloud-file-on-file-rename-returns
onFileUpload
– [Added in TB 64]
Fired when a file should be uploaded to the cloud file provider.
Parameters for onFileUpload.addListener(listener)
listener(account, fileInfo, tab, relatedFileInfo)
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
tab
The tab where the upload was initiated. Currently only available for the message composer.
relatedFileInfo
Information about an already uploaded file, which is related to this upload.
Expected return value of the listener function
cloud-file-on-file-upload-returns
aborted
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.
error
Report an error to the user. Set this to true for showing a generic error message, or set a specific error message.
templateInfo
Additional file information used in the cloud file entry added to the message.
url
The URL where the uploaded file can be accessed.
onFileUploadAbort
– [Added in TB 64]
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
An identifier for this file.
tab
Types
CloudFile
– [Added in TB 64]
Information about a cloud file.
CloudFileAccount
– [Added in TB 64]
Information about a cloud file account.
object
configured
If true, the account is configured and ready to use. Only configured accounts are offered to the user.
id
Unique identifier of the account.
managementUrl
A page for configuring accounts, to be displayed in the preferences UI.
name
A user-friendly name for this account.
spaceRemaining
The amount of remaining space on the cloud provider, in bytes. Set to -1 if unsupported.
spaceUsed
The amount of space already used on the cloud provider, in bytes. Set to -1 if unsupported.
uploadSizeLimit
The maximum size in bytes for a single file to upload. Set to -1 if unlimited.
CloudFileTemplateInfo
– [Added in TB 96]
Defines information to be used in the cloud file entry added to the message.
object
download_expiry_date
If set, the cloud file entry for this upload will include a hint, that the link will only be available for a limited time.
timestamp
The expiry date of the link as the number of milliseconds since the UNIX epoch.
format
A format options object as used by Intl.DateTimeFormat.
Defaults to:
{
"day": "2-digit",
"month": "2-digit",
"year": "numeric",
"hour": "2-digit",
"minute": "2-digit",
"timeZoneName": "short"
}
download_limit
If set, the cloud file entry for this upload will include a hint, that the file has a download limit.
download_password_protected
If set to true, the cloud file entry for this upload will include a hint, that the download link is password protected.
service_icon
A URL pointing to an icon to represent the used cloud file service. Defaults to the icon of the provider add-on.
service_name
A name to represent the used cloud file service. Defaults to the associated cloud file account name.
service_url
A URL pointing to a web page of the used cloud file service. Will be used in a Learn more about link in the footer of the cloud file attachment element.
Information about an already uploaded cloud file, which is related to a new upload. For example if the content of a cloud attachment is updated, if a repeatedly used cloud attachment is renamed (and therefore should be re-uploaded to not invalidate existing links) or if the provider has its manifest property reuse_uploads set to false.
object
dataChanged
The content of the new upload differs from the related file.
name
Filename of the related file.
id
The identifier for the related file. In some circumstances, the id is unavailable.
templateInfo
Additional information of the related file, used in the cloud file entry added to the message.
url
The URL where the upload of the related file can be accessed.