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
| Parameter | Type |
|---|---|
book | Book |
payload? | File |
Returns
File
Overrides
ResourceProperty<bkper.File>.constructorProperties
payload
payload: File;The underlying payload data for this resource
Inherited from
ResourceProperty.payloadMethods
create()
create(): Promise<File>;Perform create new File.
Returns
Promise<File>
The created File object
deleteProperty()
deleteProperty(key): this;Deletes a custom property.
Parameters
| Parameter | Type | Description |
|---|---|---|
key | string | The property key |
Returns
this
This resource, for chaining
Inherited from
ResourceProperty.deletePropertygetBook()
getBook(): Book;Gets the Book this File belongs to.
Returns
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.getPropertiesgetProperty()
getProperty(...keys): string | undefined;Gets the property value for given keys. First property found will be retrieved.
Parameters
| Parameter | Type | Description |
|---|---|---|
…keys | string[] | The property keys to search for |
Returns
string | undefined
The property value or undefined if not found
Inherited from
ResourceProperty.getPropertygetPropertyKeys()
getPropertyKeys(): string[];Gets the custom properties keys stored in this resource.
Returns
string[]
Array of property keys sorted alphabetically
Inherited from
ResourceProperty.getPropertyKeysgetSize()
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.getVisiblePropertiesjson()
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.jsonsetContent()
setContent(content): File;Sets the File content Base64 encoded.
Parameters
| Parameter | Type | Description |
|---|---|---|
content | string | The content to set (Base64 encoded) |
Returns
File
This File, for chaining
setContentType()
setContentType(contentType): File;Sets the File content type.
Parameters
| Parameter | Type | Description |
|---|---|---|
contentType | string | The content type to set |
Returns
File
This File, for chaining
setName()
setName(name): File;Sets the name of the File.
Parameters
| Parameter | Type | Description |
|---|---|---|
name | string | The name to set |
Returns
File
This File, for chaining
setProperties()
setProperties(properties): this;Sets the custom properties of this resource.
Parameters
| Parameter | Type | Description |
|---|---|---|
properties | { [key: string]: string; } | Object with key/value pair properties |
Returns
this
This resource, for chaining
Inherited from
ResourceProperty.setPropertiessetProperty()
setProperty(key, value): this;Sets a custom property in this resource.
Parameters
| Parameter | Type | Description |
|---|---|---|
key | string | The property key |
value | string | null | undefined | The property value, or null/undefined to clean it |
Returns
this
This resource, for chaining
Inherited from
ResourceProperty.setPropertysetVisibleProperties()
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
| Parameter | Type | Description |
|---|---|---|
properties | { [key: string]: string; } | Object with key/value pair properties |
Returns
this
This resource, for chaining
Inherited from
ResourceProperty.setVisiblePropertiessetVisibleProperty()
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
| Parameter | Type | Description |
|---|---|---|
key | string | The property key |
value | string | null | undefined | The property value, or null/undefined to clean it |
Returns
this
This resource, for chaining
Inherited from
ResourceProperty.setVisiblePropertyupdate()
update(): Promise<File>;Perform update File, applying pending changes.
Returns
Promise<File>
The updated File object