Skip to content

Documentation / joplin-api / ResourceApi

Class: ResourceApi

附件资源相关 api

Constructors

new ResourceApi()

new ResourceApi(ajax): ResourceApi

Parameters

ajax: Ajax

Returns

ResourceApi

Defined in

api/ResourceApi.ts:13

Methods

create()

create(param): Promise<ResourceProperties>

Creates a new resource TODO 目前大批量上传文件仍有问题 Creating a new resource is special because you also need to upload the file. Unlike other API calls, this one must have the "multipart/form-data" Content-Type. The file data must be passed to the "data" form field, and the other properties to the "props" form field. An example of a valid call with cURL would be: The "data" field is required, while the "props" one is not. If not specified, default values will be used.

Parameters

param: object & Partial<ResourceProperties>

Returns

Promise<ResourceProperties>

Defined in

api/ResourceApi.ts:44


fileById()

fileById(id): Promise<Blob>

Parameters

id: string

Returns

Promise<Blob>

Defined in

api/ResourceApi.ts:85


fileByResourceId()

fileByResourceId(id): Promise<Buffer>

Gets the actual file associated with this resource.

Parameters

id: string

Returns

Promise<Buffer>

Defined in

api/ResourceApi.ts:74


get()

get(id)

get(id): Promise<ResourceGetRes>

Parameters

id: string

Returns

Promise<ResourceGetRes>

Defined in

api/ResourceApi.ts:25

get(id, fields)

get<K>(id, fields): Promise<Pick<ResourceProperties, K> & CommonType>

Type Parameters

K extends keyof ResourceProperties = "id" | "title"

Parameters

id: string

fields: K[]

Returns

Promise<Pick<ResourceProperties, K> & CommonType>

Defined in

api/ResourceApi.ts:26


list()

list(undefined)

list(): Promise<PageRes<ResourceGetRes>>

Returns

Promise<PageRes<ResourceGetRes>>

Defined in

api/ResourceApi.ts:15

list(pageParam)

list<K>(pageParam): Promise<PageRes<Pick<ResourceProperties, K>>>

Type Parameters

K extends keyof ResourceProperties

Parameters

pageParam: PageParam<ResourceProperties> & FieldsParam<K>

Returns

Promise<PageRes<Pick<ResourceProperties, K>>>

Defined in

api/ResourceApi.ts:16


remove()

remove(id): Promise<void>

TODO 这个 api 存在 bug

Parameters

id: string

Returns

Promise<void>

Defined in

api/ResourceApi.ts:66


update()

update(param): Promise<ResourceGetRes>

Parameters

param: Required<Pick<Partial<ResourceProperties>, "id">> & Omit<Partial<ResourceProperties>, "id"> & object

Returns

Promise<ResourceGetRes>

Defined in

api/ResourceApi.ts:53

Released under the MIT License.