nx.js
NamespacesSwitchClasses

AlbumFile

Represents a file within a Switch.Album content store, which is either a screenshot (JPEG image) or a screen recording (MP4 movie).

It is a subclass of File, so you can use familiar features like name, lastModified and arrayBuffer(). It also has additional metadata like applicationId to determine which application generated the contents.

Example

const ctx = screen.getContext('2d');
const buf = await file.arrayBuffer();
const img = await createImageBitmap(new Blob([buf]));
ctx.drawImage(img, 0, 0);

Extends

Constructors

new AlbumFile()

new AlbumFile(storage, id): AlbumFile

Parameters

ParameterType
storagenumber
idstring

Returns

AlbumFile

Overrides

File.constructor

Properties

PropertyTypeDescriptionInherited from
applicationIdbigintThe ID of the application which generated the album file.-
contentnumberThe type of content which the album file contains. The value corresponds with the CapsAlbumFileContents enum from @nx.js/constants.-
idnumberUnique ID for when there's multiple album files with the same timestamp. Note The value is usually 0.-
lastModifiednumber-File.lastModified
namestring-File.name
storagenumberThe storage device which contains the album file. The value corresponds with the CapsAlbumStorage enum from @nx.js/constants.-
webkitRelativePathstring-File.webkitRelativePath

Accessors

size

get size(): number

Returns the size of the Blob object, in bytes.

Returns

number

Inherited from

File.size


type

get type(): string

Returns the MIME type of the Blob object.

Returns

string

Inherited from

File.type

Methods

arrayBuffer()

arrayBuffer(): Promise<ArrayBuffer>

Returns a promise that resolves with an ArrayBuffer representing the Blob's data.

Returns

Promise<ArrayBuffer>

Inherited from

File.arrayBuffer


slice()

slice(start?, end?, type?): Blob

Returns a new Blob object containing the data in the specified range of bytes of the source Blob.

Parameters

ParameterTypeDescription
start?numberThe start byte index.
end?numberThe end byte index.
type?stringThe content type of the new Blob.

Returns

Blob

Overrides

File.slice


stream()

Returns a stream that can be used to read the contents of the Blob.

Returns

ReadableStream<Uint8Array>

Overrides

File.stream


text()

text(): Promise<string>

Returns a promise that resolves with a string representation of the Blob object.

Returns

Promise<string>

Overrides

File.text


thumbnail()

thumbnail(): Promise<ArrayBuffer>

Loads the thumbnail JPEG image for the album file.

Returns

Promise<ArrayBuffer>

Example

const ctx = screen.getContext('2d');
const buf = await file.thumbnail();
const img = await createImageBitmap(new Blob([buf]));
ctx.drawImage(img, 0, 0);

On this page