Skip to content

ppagent / AsyncFile

Class: AsyncFile

Defined in: src/util/async.file.ts:39

Implements

Constructors

Constructor

new AsyncFile(loader, format): AsyncFile

Defined in: src/util/async.file.ts:45

init async file.use loader to load init data.

Parameters

loader

AsyncFileLoader

format

"text" | "binary"

Returns

AsyncFile

Accessors

name

Get Signature

get name(): string

Defined in: src/util/async.file.ts:61

Returns

string

Implementation of

IAsyncFile.name

Methods

asBase64()

asBase64(): Promise<string>

Defined in: src/util/async.file.ts:206

Returns

Promise<string>

Implementation of

IAsyncFile.asBase64


asBuffer()

asBuffer(): Promise<Buffer<ArrayBufferLike>>

Defined in: src/util/async.file.ts:171

Returns

Promise<Buffer<ArrayBufferLike>>

Implementation of

IAsyncFile.asBuffer


asLocalPath()

asLocalPath(): Promise<string>

Defined in: src/util/async.file.ts:255

Returns

Promise<string>

Implementation of

IAsyncFile.asLocalPath


asPath()

asPath(): Promise<string>

Defined in: src/util/async.file.ts:197

Returns

Promise<string>

Implementation of

IAsyncFile.asPath


asReadStream()

asReadStream(): Promise<ReadStream>

Defined in: src/util/async.file.ts:268

Returns

Promise<ReadStream>

Implementation of

IAsyncFile.asReadStream


asText()

asText(): Promise<string>

Defined in: src/util/async.file.ts:216

Returns

Promise<string>

Implementation of

IAsyncFile.asText


asUrl()

asUrl(): Promise<string>

Defined in: src/util/async.file.ts:234

确保该文件可以通过url访问,该文件将被复制到public/temp/目录下,同时根据config中httpUrl生成访问路径

Returns

Promise<string>

Implementation of

IAsyncFile.asUrl


getFormat()

getFormat(): "text" | "binary"

Defined in: src/util/async.file.ts:167

Returns

"text" | "binary"

Implementation of

IAsyncFile.getFormat


info()

info(): Promise<Stats>

Defined in: src/util/async.file.ts:274

Returns

Promise<Stats>

Implementation of

IAsyncFile.info


isAsyncFile()

isAsyncFile(): boolean

Defined in: src/util/async.file.ts:290

Returns

boolean

Implementation of

IAsyncFile.isAsyncFile


saveAs()

saveAs(dir, bucket, name?, onCompleted?): string

Defined in: src/util/async.file.ts:152

Parameters

dir

string

bucket

string

name?

string

onCompleted?

() => void

Returns

string


toString()

toString(): string

Defined in: src/util/async.file.ts:294

Returns a string representation of an object.

Returns

string


fromBuffer()

static fromBuffer(buffer, name?, format?, textEncoding?): AsyncFile

Defined in: src/util/async.file.ts:328

从buffer创建

Parameters

buffer

Buffer

name?

string

format?

"text" | "binary"

textEncoding?

BufferEncoding

Returns

AsyncFile


fromPath()

static fromPath(userPath, format, fileName?, textEncoding?): AsyncFile

Defined in: src/util/async.file.ts:304

从本地路径或者网络url创建

Parameters

userPath

string

format

"text" | "binary"

fileName?

string

textEncoding?

BufferEncoding

Returns

AsyncFile