Wiki source code of Front-End Attachments API
Last modified by Manuel Leduc on 2026/02/05 17:22
Hide last authors
| author | version | line-number | content |
|---|---|---|---|
| |
1.1 | 1 | {{code language="typescript"}} |
| 2 | /** | ||
| 3 | * @since 0.9 | ||
| 4 | */ | ||
| 5 | interface Attachment { | ||
| 6 | id: string; | ||
| 7 | name: string; | ||
| 8 | mimetype: string; | ||
| 9 | href: string; | ||
| 10 | } | ||
| 11 | |||
| 12 | interface AttachmentsService { | ||
| 13 | list(): Ref<Attachment[]>; | ||
| 14 | |||
| 15 | count(): Ref<number>; | ||
| 16 | |||
| 17 | isLoading(): Ref<boolean>; | ||
| 18 | |||
| 19 | /** | ||
| 20 | * True while an attachment is uploading. | ||
| 21 | */ | ||
| 22 | isUploading(): Ref<boolean>; | ||
| 23 | |||
| 24 | getError(): Ref<string | undefined>; | ||
| 25 | |||
| 26 | /** | ||
| 27 | * Load the initial state of the attachments. | ||
| 28 | */ | ||
| 29 | refresh(page: string): Promise<void>; | ||
| 30 | |||
| 31 | /** | ||
| 32 | * Upload the provided list of files to a given page | ||
| 33 | * @param page - the page where to save the files | ||
| 34 | * @param files - the list of files to upload | ||
| 35 | * @returns (since 0.20) an optional list of resolved attachments URL (in the same order as the provided files). This | ||
| 36 | * is useful in the case where the url cannot be resolved from the name of the file and its document reference | ||
| 37 | * alone. | ||
| 38 | */ | ||
| 39 | upload( | ||
| 40 | page: string, | ||
| 41 | files: File[], | ||
| 42 | ): Promise<(string | undefined)[] | undefined>; | ||
| 43 | } | ||
| 44 | {{/code}} |