Skip to main content

BinaryMap

@webda/core


Class: BinaryMap<T>

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

This is a map used to retrieve binary

BinaryMap

Extends​

Extended by​

Type Parameters​

T​

T extends object = { }

Constructors​

Constructor​

new BinaryMap<T>(service, obj): BinaryMap<T>

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

Create a new BinaryMap

Parameters​

service​

BinaryService

the binary service

obj​

BinaryFileInfo<T>

the binary file information

Returns​

BinaryMap<T>

Overrides​

BinaryFile.constructor

Properties​

[WEBDA_STORAGE]​

[WEBDA_STORAGE]: object

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

Link to the binary store

service​

service: BinaryService


challenge?​

optional challenge?: string

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

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​

BinaryFile.challenge


hash?​

optional hash?: string

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

Will be computed by the service

hash of the content

Inherited from​

BinaryFile.hash


metadata?​

optional metadata?: T

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

Metadatas stored along with the binary

Inherited from​

BinaryFile.metadata


mimetype​

mimetype: string

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

Mimetype of the binary

Inherited from​

BinaryFile.mimetype


name​

name: string

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

Current name

Inherited from​

BinaryFile.name


originalname?​

optional originalname?: string

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

Original name

Inherited from​

BinaryFile.originalname


size​

size: number

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

Size of the binary

Inherited from​

BinaryFile.size

Methods​

computeHashes()​

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

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

Compute the hashes from the content, whatever hash or challenge is already set

The hash is the md5 of the bytes, the challenge the md5 of "WEBDA" followed by the bytes

Returns​

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

the computed hash and challenge

Inherited from​

BinaryFile.computeHashes


downloadTo()​

downloadTo(filename): Promise<void>

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

Download the binary to a path

Shortcut to call Binary.downloadTo with current object

Parameters​

filename​

string

the filename

Returns​

Promise<void>

the result


get()​

get(): Promise<Readable>

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

Get the binary data

Returns​

Promise<Readable>

the result

Overrides​

BinaryFile.get


getAsBuffer()​

getAsBuffer(): Promise<Buffer<ArrayBufferLike>>

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

Get into a buffer

Returns​

Promise<Buffer<ArrayBufferLike>>

the result


getHashes()​

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

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

Create hashes, computed from the content unless a hash is already set

Returns​

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

the result

Inherited from​

BinaryFile.getHashes


set()​

set(info): void

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

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

Overrides​

BinaryFile.set


toBinaryFileInfo()​

toBinaryFileInfo(): BinaryFileInfo<T>

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

Retrieve a plain BinaryFileInfo object

Returns​

BinaryFileInfo<T>

the result

Inherited from​

BinaryFile.toBinaryFileInfo


toJSON()​

toJSON(): StoredBinaryInfo<T>

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

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