# Class JFileApi

#### Hierarchy (View Summary)

- JBaseApi
  - JFileApi

- Defined in jamespot-user-api/src/apis/file/file.ts:15

##### Index

### Constructors

constructor

### Properties

jApi
network

### Methods

copy
deleteFile
deleteImage
duplicate
generatePreview
get
getDownload
getParent
getWithHash
update
updateFile
upload
uploadMany

## Constructors

### constructor

- new JFileApi(jApi: JamespotUserApi): JFileApi

  #### Parameters

  - jApi: JamespotUserApi

  #### Returns JFileApi

  Inherited from JBaseApi.constructor

  - Defined in jamespot-user-api/src/apis/base.ts:8

## Properties

### jApi

jApi: JamespotUserApi

Inherited from JBaseApi.jApi

- Defined in jamespot-user-api/src/apis/base.ts:5

### network

network: Network

Inherited from JBaseApi.network

- Defined in jamespot-user-api/src/apis/base.ts:6

## Methods

### copy

- copy<T extends jFileLittle = jFileLittle>(
  params: FileCopyParams,
  options?: {
  format?: "raw-little" | "raw-list" | "raw-view";
  signal?: AbortSignal;
  },
  ): Promise<ApiWrapper<T, BaseMessages>>

  #### Type Parameters

  - T extends jFileLittle = jFileLittle

  #### Parameters

  - params: FileCopyParams
  - `Optional` options: { format?: "raw-little" | "raw-list" | "raw-view"; signal?: AbortSignal }

  #### Returns Promise<ApiWrapper<T, BaseMessages>>

  - Defined in jamespot-user-api/src/apis/file/file.ts:222

### deleteFile

- deleteFile(
  idFile: string | number,
  attrName: string,
  token: string,
  signal?: AbortSignal,
  ): Promise<ApiWrapper<boolean, BaseMessages>>

  delete file. This action is not automatic. You need to update the content associated with the deleted image with the same token

  #### Parameters

  - idFile: string | number

    file id

  - attrName: string

    attribute name

  - token: string

    token

  - `Optional` signal: AbortSignal

  #### Returns Promise<ApiWrapper<boolean, BaseMessages>>

  - Defined in jamespot-user-api/src/apis/file/file.ts:160

### deleteImage

- deleteImage(
  id: string | number,
  type: string,
  options?: { signal?: AbortSignal },
  ): Promise<ApiWrapper<{ id: number }, BaseMessages>>

  delete the image associated with a content. This action is permanent. There is no two step process with a token

  #### Parameters

  - id: string | number

    content id

  - type: string

    content type

  - `Optional` options: { signal?: AbortSignal }

  #### Returns Promise<ApiWrapper<{ id: number }, BaseMessages>>

  - Defined in jamespot-user-api/src/apis/file/file.ts:180

### duplicate

- duplicate(
  idFile: number,
  title: string,
  publishTo?: string[],
  ): Promise<
  ApiWrapper<{ article: jArticleLittle; idFile: number }, BaseMessages>,
  >

  #### Parameters

  - idFile: number
  - title: string
  - `Optional` publishTo: string[]

  #### Returns Promise<ApiWrapper<{ article: jArticleLittle; idFile: number }, BaseMessages>>

  - Defined in jamespot-user-api/src/apis/file/file.ts:96

### generatePreview

- generatePreview(
  id: number,
  options?: { signal?: AbortSignal },
  ): Promise<ApiWrapper<boolean, BaseMessages>>

  #### Parameters

  - id: number
  - `Optional` options: { signal?: AbortSignal }

  #### Returns Promise<ApiWrapper<boolean, BaseMessages>>

  - Defined in jamespot-user-api/src/apis/file/file.ts:211

### get

- get<T extends jFileLittle>(
  idFile: number,
  format?: "raw-little" | "raw-list" | "raw-view",
  options?: { signal?: AbortSignal },
  ): Promise<ApiWrapper<T, BaseMessages>>

  #### Type Parameters

  - T extends jFileLittle

  #### Parameters

  - idFile: number
  - `Optional` format: "raw-little" | "raw-list" | "raw-view"
  - `Optional` options: { signal?: AbortSignal }

  #### Returns Promise<ApiWrapper<T, BaseMessages>>

  - Defined in jamespot-user-api/src/apis/file/file.ts:40

### getDownload

- getDownload(
  id: number,
  options?: { signal?: AbortSignal },
  ): Promise<
  ApiWrapper<{ count: number; list: UserDownload[] }, BaseMessages>,
  >

  #### Parameters

  - id: number
  - `Optional` options: { signal?: AbortSignal }

  #### Returns Promise<ApiWrapper<{ count: number; list: UserDownload[] }, BaseMessages>>

  - Defined in jamespot-user-api/src/apis/file/file.ts:192

### getParent

- getParent<T extends jObjectLittle>(
  idFile: number,
  format?: "raw-little" | "raw-list" | "raw-view",
  hash?: string,
  options?: { signal?: AbortSignal },
  ): Promise<ApiWrapper<T, BaseMessages>>

  #### Type Parameters

  - T extends jObjectLittle

  #### Parameters

  - idFile: number
  - `Optional` format: "raw-little" | "raw-list" | "raw-view"
  - `Optional` hash: string
  - `Optional` options: { signal?: AbortSignal }

  #### Returns Promise<ApiWrapper<T, BaseMessages>>

  - Defined in jamespot-user-api/src/apis/file/file.ts:58

### getWithHash

- getWithHash<T extends jFileLittle>(
  idFile: number,
  hash: string,
  format?: "raw-little" | "raw-list" | "raw-view",
  options?: { signal?: AbortSignal },
  ): Promise<ApiWrapper<T, BaseMessages>>

  #### Type Parameters

  - T extends jFileLittle

  #### Parameters

  - idFile: number
  - hash: string
  - `Optional` format: "raw-little" | "raw-list" | "raw-view"
  - `Optional` options: { signal?: AbortSignal }

  #### Returns Promise<ApiWrapper<T, BaseMessages>>

  - Defined in jamespot-user-api/src/apis/file/file.ts:78

### update

- update(
  idFile: string | number,
  type: string,
  config: FileCropConfig,
  options?: { signal?: AbortSignal },
  ): Promise<ApiWrapper<jFileLittleCrop, BaseMessages>>

  Crop an image

  #### Parameters

  - idFile: string | number
  - type: string
  - config: FileCropConfig

    crop configuration

  - `Optional` options: { signal?: AbortSignal }

  #### Returns Promise<ApiWrapper<jFileLittleCrop, BaseMessages>>

  - Defined in jamespot-user-api/src/apis/file/file.ts:127

### updateFile

- updateFile(
  idFile: number,
  title: string,
  ): Promise<ApiWrapper<boolean, BaseMessages>>

  #### Parameters

  - idFile: number
  - title: string

  #### Returns Promise<ApiWrapper<boolean, BaseMessages>>

  - Defined in jamespot-user-api/src/apis/file/file.ts:110

### upload

- upload(
  config: UploadConfig,
  ): Promise<
  { response: ApiWrapper<jFileLittle, BaseMessages>; token: string },
  >

  Upload a file to the server. use the same token to link the file to an article

  #### Parameters

  - config: UploadConfig

    configuration object. One of "file" and "url" is mandatory

  #### Returns Promise<{ response: ApiWrapper<jFileLittle, BaseMessages>; token: string }>

  - Defined in jamespot-user-api/src/apis/file/file.ts:20

### uploadMany

- uploadMany(
  configArray: UploadConfig[],
  ): Promise<
  { response: ApiWrapper<jFileLittle, BaseMessages>; token: string }[],
  >

  Upload a list of files to the server. use the same token to link the file to an article

  #### Parameters

  - configArray: UploadConfig[]

  #### Returns Promise<{ response: ApiWrapper<jFileLittle, BaseMessages>; token: string }[]>

  - Defined in jamespot-user-api/src/apis/file/file.ts:36