Class: Attachment

Attachment

new Attachment(jmap, blobId, optsopt)

This class represents a JMAP Attachment.
An Attachment object holds all information of a given attachment of a Message.

Parameters:
Name Type Attributes Description
jmap Client

The Client instance that created the parent Message.

blobId String

The id of the binary data.

opts Object <optional>

The optional properties of this Attachment.

Properties
Name Type Attributes Default Description
url String <optional>
null

The URL to download the attachment. If not passed as a parameter, this will be deduced from the configured downloadUrl of the Client instance used to fetch the Message containing this Attachment. If the library does not find a reliable way of knowing the URL for this attachment, for any reason, the url property of this Attachment instance will be set to null.

type String <optional>
''

The content-type of the attachment.

name String <optional>
''

The full file name.

size Number <optional>
null

The size, in bytes, of the attachment when fully decoded.

cid String <optional>
null

The id used within the message body to reference this attachment.

isInline String <optional>
false

true if the attachment is referenced by a cid: link from within the HTML body of the message.

width String <optional>
null

The width (in px) of the image, if the attachment is an image.

height String <optional>
null

TThe height (in px) of the image, if the attachment is an image.

Source:
See:

Extends

Methods

(static) fromJSONObject(jmap, object) → {Attachment}

Creates an Attachment from its JSON representation.

Parameters:
Name Type Description
jmap Client

The Client instance used to fetch the parent Message.

object Object

The JSON representation of the Attachment, as a Javascript object.

Properties
Name Type Description
blobId String

The id of the binary data for this Attachment.

Source:
Returns:
Type
Attachment

getSignedDownloadUrl() → {Promise}

Gets a signed download URL for this Attachment. Details of this process can be found in the spec.
This mandates that url is defined on this Attachment instance, otherwise we cannot get a signed URL.

Source:
Throws:

If this Attachment instance has no URL available.

Type
Error
Returns:

A Promise eventually resolving to the signed download URL.

Type
Promise

toJSONObject()

Creates a JSON representation from this model.

Source:
Returns:

JSON object with only owned properties and non default values.