Skip to content

File

This class defines a File uploaded to a [[Book]].

A File can be attached to a [[Transaction]] or used to import data.

Extends

  • ResourceProperty<bkper.File>

Constructors

Constructor

new File(book, payload?): File;

Parameters

ParameterType
bookBook
payload?File

Returns

File

Overrides

ResourceProperty<bkper.File>.constructor

Properties

payload

payload: File;

The underlying payload data for this resource

Inherited from

ResourceProperty.payload

Methods

create()

create(): Promise<File>;

Perform create new File.

Returns

Promise<File>

The created File object


deleteProperty()

deleteProperty(key): this;

Deletes a custom property.

Parameters

ParameterTypeDescription
keystringThe property key

Returns

this

This resource, for chaining

Inherited from

ResourceProperty.deleteProperty

getBook()

getBook(): Book;

Gets the Book this File belongs to.

Returns

Book

The Book instance that owns this File


getContent()

getContent(): Promise<string | undefined>;

Gets the file content Base64 encoded.

Returns

Promise<string | undefined>

The file content Base64 encoded


getContentType()

getContentType(): string | undefined;

Gets the File content type.

Returns

string | undefined

The File content type


getId()

getId(): string | undefined;

Gets the File id.

Returns

string | undefined

The File id


getName()

getName(): string | undefined;

Gets the File name.

Returns

string | undefined

The File name


getProperties()

getProperties(): object;

Gets the custom properties stored in this resource.

Returns

object

Object with key/value pair properties

Inherited from

ResourceProperty.getProperties

getProperty()

getProperty(...keys): string | undefined;

Gets the property value for given keys. First property found will be retrieved.

Parameters

ParameterTypeDescription
keysstring[]The property keys to search for

Returns

string | undefined

The property value or undefined if not found

Inherited from

ResourceProperty.getProperty

getPropertyKeys()

getPropertyKeys(): string[];

Gets the custom properties keys stored in this resource.

Returns

string[]

Array of property keys sorted alphabetically

Inherited from

ResourceProperty.getPropertyKeys

getSize()

getSize(): number | undefined;

Gets the file size in bytes.

Returns

number | undefined

The file size in bytes


getUrl()

getUrl(): string | undefined;

Gets the file serving url for accessing via browser.

Returns

string | undefined

The file serving url


getVisibleProperties()

getVisibleProperties(): object;

Gets the visible custom properties stored in this resource. Hidden properties (those ending with ”_”) are excluded from the result.

Returns

object

Object with key/value pair properties, excluding hidden properties

Inherited from

ResourceProperty.getVisibleProperties

json()

json(): File;

Gets an immutable copy of the JSON payload for this resource.

Returns

File

An immutable copy of the json payload

Inherited from

ResourceProperty.json

setContent()

setContent(content): File;

Sets the File content Base64 encoded.

Parameters

ParameterTypeDescription
contentstringThe content to set (Base64 encoded)

Returns

File

This File, for chaining


setContentType()

setContentType(contentType): File;

Sets the File content type.

Parameters

ParameterTypeDescription
contentTypestringThe content type to set

Returns

File

This File, for chaining


setName()

setName(name): File;

Sets the name of the File.

Parameters

ParameterTypeDescription
namestringThe name to set

Returns

File

This File, for chaining


setProperties()

setProperties(properties): this;

Sets the custom properties of this resource.

Parameters

ParameterTypeDescription
properties{ [key: string]: string; }Object with key/value pair properties

Returns

this

This resource, for chaining

Inherited from

ResourceProperty.setProperties

setProperty()

setProperty(key, value): this;

Sets a custom property in this resource.

Parameters

ParameterTypeDescription
keystringThe property key
valuestring | null | undefinedThe property value, or null/undefined to clean it

Returns

this

This resource, for chaining

Inherited from

ResourceProperty.setProperty

setVisibleProperties()

setVisibleProperties(properties): this;

Sets the custom properties of this resource, filtering out hidden properties. Hidden properties are those whose keys end with an underscore ”_”.

Parameters

ParameterTypeDescription
properties{ [key: string]: string; }Object with key/value pair properties

Returns

this

This resource, for chaining

Inherited from

ResourceProperty.setVisibleProperties

setVisibleProperty()

setVisibleProperty(key, value): this;

Sets a custom property in this resource, filtering out hidden properties. Hidden properties are those whose keys end with an underscore ”_”.

Parameters

ParameterTypeDescription
keystringThe property key
valuestring | null | undefinedThe property value, or null/undefined to clean it

Returns

this

This resource, for chaining

Inherited from

ResourceProperty.setVisibleProperty

update()

update(): Promise<File>;

Perform update File, applying pending changes.

Returns

Promise<File>

The updated File object