Skip to main content

BinariesItem

@webda/core


Class: BinariesItem<T>

Defined in: packages/core/src/services/binary.service.ts:712

Define a Binary map stored in a Binaries collection

Extends​

Type Parameters​

T​

T extends object = { }

Constructors​

Constructor​

new BinariesItem<T>(parent, info): BinariesItem<T>

Defined in: packages/core/src/services/binary.service.ts:722

Create a new BinariesItem

Parameters​

parent​

BinariesImpl<T>

the parent binaries collection

info​

BinaryFileInfo<T>

the binary file information

Returns​

BinariesItem<T>

Overrides​

BinaryMap.constructor

Properties​

[WEBDA_STORAGE]​

[WEBDA_STORAGE]: object

Defined in: packages/core/src/services/binary.service.ts:713

Link to the binary store

parent​

parent: BinariesImpl<T>

service​

service: BinaryService

Overrides​

BinaryMap.[WEBDA_STORAGE]


challenge?​

optional challenge?: string

Defined in: packages/core/src/services/binary.service.ts:143

Proof of possession of the content: hash of the content prefixed by 'WEBDA', computed by the client of the challenge and by the service on upload. Never persisted on a model nor sent to clients: it is not part of the schema of a binary attribute

Schema Ignore​

Inherited from​

BinaryMap.challenge


hash?​

optional hash?: string

Defined in: packages/core/src/services/binary.service.ts:149

Will be computed by the service

hash of the content

Inherited from​

BinaryMap.hash


metadata?​

optional metadata?: T

Defined in: packages/core/src/services/binary.service.ts:153

Metadatas stored along with the binary

Inherited from​

BinaryMap.metadata


mimetype​

mimetype: string

Defined in: packages/core/src/services/binary.service.ts:136

Mimetype of the binary

Inherited from​

BinaryMap.mimetype


name​

name: string

Defined in: packages/core/src/services/binary.service.ts:124

Current name

Inherited from​

BinaryMap.name


originalname?​

optional originalname?: string

Defined in: packages/core/src/services/binary.service.ts:128

Original name

Inherited from​

BinaryMap.originalname


size​

size: number

Defined in: packages/core/src/services/binary.service.ts:132

Size of the binary

Inherited from​

BinaryMap.size

Methods​

delete()​

delete(): Promise<void>

Defined in: packages/core/src/services/binary.service.ts:742

Delete the binary, if you need to replace just use upload

Returns​

Promise<void>

the result


downloadTo()​

downloadTo(filename): Promise<void>

Defined in: packages/core/src/services/binary.service.ts:355

Download the binary to a path

Shortcut to call Binary.downloadTo with current object

Parameters​

filename​

string

the filename

Returns​

Promise<void>

the result

Inherited from​

BinaryMap.downloadTo


get()​

get(): Promise<Readable>

Defined in: packages/core/src/services/binary.service.ts:316

Get the binary data

Returns​

Promise<Readable>

the result

Inherited from​

BinaryMap.get


getAsBuffer()​

getAsBuffer(): Promise<Buffer<ArrayBufferLike>>

Defined in: packages/core/src/services/binary.service.ts:343

Get into a buffer

Returns​

Promise<Buffer<ArrayBufferLike>>

the result

Inherited from​

BinaryMap.getAsBuffer


getHashes()​

getHashes(): Promise<{ challenge: string; hash: string; }>

Defined in: packages/core/src/services/binary.service.ts:198

Create hashes

Returns​

Promise<{ challenge: string; hash: string; }>

the result

Inherited from​

BinaryMap.getHashes


set()​

set(info): void

Defined in: packages/core/src/services/binary.service.ts:324

A map never holds the challenge: maps persisted before it was hidden carry one, it is not loaded

Parameters​

info​

BinaryFileInfo<T>

the information object

Returns​

void

Inherited from​

BinaryMap.set


toBinaryFileInfo()​

toBinaryFileInfo(): BinaryFileInfo<T>

Defined in: packages/core/src/services/binary.service.ts:179

Retrieve a plain BinaryFileInfo object

Returns​

BinaryFileInfo<T>

the result

Inherited from​

BinaryMap.toBinaryFileInfo


toJSON()​

toJSON(): StoredBinaryInfo<T>

Defined in: packages/core/src/services/binary.service.ts:334

Client representation: the file information without the challenge, which is the proof of possession of the content (md5 of "WEBDA" + content) and must never reach a reader of the object

Returns​

StoredBinaryInfo<T>

the file information

Inherited from​

BinaryMap.toJSON


upload()​

upload(file): Promise<void>

Defined in: packages/core/src/services/binary.service.ts:733

Replace the binary

Parameters​

file​

BinaryFile<T>

the file path

Returns​

Promise<void>

the result