Skip to main content

BinaryFile

@webda/core


Abstract Class: BinaryFile<T>

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

Represent a file to store

Webda Schema​

Extended by​

Type Parameters​

T​

T extends object = { }

Implements​

Constructors​

Constructor​

new BinaryFile<T>(info): BinaryFile<T>

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

Create a new BinaryFile

Parameters​

info​

BinaryFileInfo<T>

the binary file information

Returns​

BinaryFile<T>

Properties​

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​

Implementation of​

BinaryFileInfo.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

Implementation of​

BinaryFileInfo.hash


metadata?​

optional metadata?: T

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

Metadatas stored along with the binary

Implementation of​

BinaryFileInfo.metadata


mimetype​

mimetype: string

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

Mimetype of the binary

Implementation of​

BinaryFileInfo.mimetype


name​

name: string

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

Current name

Implementation of​

BinaryFileInfo.name


originalname?​

optional originalname?: string

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

Original name


size​

size: number

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

Size of the binary

Implementation of​

BinaryFileInfo.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


get()​

abstract get(): Promise<Readable>

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

Returns​

Promise<Readable>


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


set()​

set(info): void

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

Set the information

Parameters​

info​

BinaryFileInfo<T>

the information object

Returns​

void


toBinaryFileInfo()​

toBinaryFileInfo(): BinaryFileInfo<T>

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

Retrieve a plain BinaryFileInfo object

Returns​

BinaryFileInfo<T>

the result