Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ResourceApi

附件资源相关 api

Hierarchy

  • ResourceApi

Index

Constructors

constructor

Methods

create

  • create(param: { data: ReadStream } & Partial<ResourceProperties>): Promise<ResourceGetRes>
  • 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: { data: ReadStream } & Partial<ResourceProperties>

    Returns Promise<ResourceGetRes>

fileByResourceId

  • fileByResourceId(id: string): Promise<Buffer>
  • Gets the actual file associated with this resource.

    Parameters

    • id: string

    Returns Promise<Buffer>

get

  • get(id: string): Promise<ResourceGetRes>
  • get<K>(id: string, fields: K[]): Promise<Pick<ResourceProperties, K> & CommonType>
  • Parameters

    • id: string

    Returns Promise<ResourceGetRes>

  • Type parameters

    • K: keyof ResourceProperties = "id" | "title"

    Parameters

    • id: string
    • fields: K[]

    Returns Promise<Pick<ResourceProperties, K> & CommonType>

list

  • list(): Promise<PageRes<ResourceGetRes>>
  • list<K>(pageParam: PageParam<ResourceProperties> & FieldsParam<K>): Promise<PageRes<Pick<ResourceProperties, K>>>
  • Returns Promise<PageRes<ResourceGetRes>>

  • Type parameters

    • K: keyof ResourceProperties

    Parameters

    • pageParam: PageParam<ResourceProperties> & FieldsParam<K>

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

remove

  • remove(id: string): Promise<void>
  • TODO 这个 api 存在 bug

    Parameters

    • id: string

    Returns Promise<void>

update

  • update(param: Required<Pick<Partial<ResourceProperties>, "id">> & Omit<Partial<ResourceProperties>, "id"> & { data?: ReadStream }): Promise<ResourceGetRes>
  • Parameters

    • param: Required<Pick<Partial<ResourceProperties>, "id">> & Omit<Partial<ResourceProperties>, "id"> & { data?: ReadStream }

    Returns Promise<ResourceGetRes>

Generated using TypeDoc