Skip to content

Files

Filename / URL / download helpers.

Functions

downloadBlob()

function downloadBlob(blob, filename): void;

Defined in: src/shared/format/files.ts:110

Triggers a browser download of an in-memory blob.

Parameters

Parameter Type Description
blob Blob The blob to download.
filename string The download filename.

Returns

void


downloadFromUrl()

function downloadFromUrl(url, filename): Promise<void>;

Defined in: src/shared/format/files.ts:95

Triggers a browser download of a fetched blob from a media URL.

Parameters

Parameter Type Description
url string The (already resolved) URL to fetch.
filename string The download filename.

Returns

Promise\<void>

Resolves once the download is triggered.


getFileExtension()

function getFileExtension(filenameOrUrl): string;

Defined in: src/shared/format/files.ts:60

Returns a file's extension (without query string), or "".

Parameters

Parameter Type Description
filenameOrUrl string | undefined A filename or URL.

Returns

string

The extension.


inferFileType()

function inferFileType(name): string | undefined;

Defined in: src/shared/format/files.ts:30

A coarse file-type tag inferred from the extension (for display + filtering).

Parameters

Parameter Type Description
name string The file name.

Returns

string | undefined

video / audio / srt, or undefined.


staticUrl()

function staticUrl(path): string;

Defined in: src/shared/format/files.ts:85

Resolves a server-relative media path (e.g. /media/...) to a fetchable URL behind the API base.

Parameters

Parameter Type Description
path string The server path.

Returns

string

An absolute URL under the API base.


truncateFilename()

function truncateFilename(filename, startChars?, endChars?): string;

Defined in: src/shared/format/files.ts:46

Truncates a filename to start…end when it's longer than the budget.

Parameters

Parameter Type Default value Description
filename string | undefined undefined The filename.
startChars? number 8 Leading chars to keep.
endChars? number 4 Trailing chars to keep.

Returns

string

The (possibly) truncated name.


truncateText()

function truncateText(text, maxLength?): string;

Defined in: src/shared/format/files.ts:73

Truncates free text with an ellipsis.

Parameters

Parameter Type Default value Description
text string | undefined undefined The text.
maxLength? number 50 The maximum length.

Returns

string

The truncated text.