Documentation / joplin-api / ResourceApi
Class: ResourceApi
附件资源相关 api
Constructors
new ResourceApi()
new ResourceApi(
ajax
):ResourceApi
Parameters
• ajax: Ajax
Returns
Defined in
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
fileById()
fileById(
id
):Promise
<Blob
>
Parameters
• id: string
Returns
Promise
<Blob
>
Defined in
fileByResourceId()
fileByResourceId(
id
):Promise
<Buffer
>
Gets the actual file associated with this resource.
Parameters
• id: string
Returns
Promise
<Buffer
>
Defined in
get()
get(id)
get(
id
):Promise
<ResourceGetRes
>
Parameters
• id: string
Returns
Promise
<ResourceGetRes
>
Defined in
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
list()
list(undefined)
list():
Promise
<PageRes
<ResourceGetRes
>>
Returns
Promise
<PageRes
<ResourceGetRes
>>
Defined in
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
remove()
remove(
id
):Promise
<void
>
TODO 这个 api 存在 bug
Parameters
• id: string
Returns
Promise
<void
>
Defined in
update()
update(
param
):Promise
<ResourceGetRes
>
Parameters
• param: Required
<Pick
<Partial
<ResourceProperties
>, "id"
>> & Omit
<Partial
<ResourceProperties
>, "id"
> & object
Returns
Promise
<ResourceGetRes
>