1
0
Fork 0
mirror of synced 2024-07-07 07:25:56 +12:00
appwrite/app/sdks/server-php/docs/storage.md

128 lines
5 KiB
Markdown
Raw Normal View History

2019-05-09 18:54:39 +12:00
# Storage Service
## List Files
```http request
2019-10-09 17:16:38 +13:00
GET https://appwrite.io/v1/storage/files
2019-05-09 18:54:39 +12:00
```
2019-12-08 09:32:15 +13:00
** Get a list of all the user files. You can use the query params to filter your results. On admin mode, this endpoint will return a list of all of the project files. [Learn more about different API modes](/docs/admin). **
2019-05-09 18:54:39 +12:00
### Parameters
| Field Name | Type | Description | Default |
| --- | --- | --- | --- |
| search | string | Search term to filter your list results. | |
| limit | integer | Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request. | 25 |
| offset | integer | Results offset. The default value is 0. Use this param to manage pagination. | 0 |
| orderType | string | Order result by ASC or DESC order. | ASC |
## Create File
```http request
2019-10-09 17:16:38 +13:00
POST https://appwrite.io/v1/storage/files
2019-05-09 18:54:39 +12:00
```
2019-10-09 21:40:02 +13:00
** Create a new file. The user who creates the file will automatically be assigned to read and write access unless he has passed custom values for read and write arguments. **
2019-05-09 18:54:39 +12:00
### Parameters
| Field Name | Type | Description | Default |
| --- | --- | --- | --- |
2020-02-14 19:28:54 +13:00
| file | file | Binary File. | |
2019-11-21 07:51:55 +13:00
| read | array | An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. | |
| write | array | An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. | |
2019-05-09 18:54:39 +12:00
## Get File
```http request
2019-10-09 17:16:38 +13:00
GET https://appwrite.io/v1/storage/files/{fileId}
2019-05-09 18:54:39 +12:00
```
2019-10-09 21:40:02 +13:00
** Get file by its unique ID. This endpoint response returns a JSON object with the file metadata. **
2019-05-09 18:54:39 +12:00
### Parameters
| Field Name | Type | Description | Default |
| --- | --- | --- | --- |
| fileId | string | **Required** File unique ID. | |
2019-08-29 00:37:13 +12:00
## Update File
```http request
2019-10-09 17:16:38 +13:00
PUT https://appwrite.io/v1/storage/files/{fileId}
2019-08-29 00:37:13 +12:00
```
2019-10-09 21:40:02 +13:00
** Update file by its unique ID. Only users with write permissions have access to update this resource. **
2019-08-29 00:37:13 +12:00
### Parameters
| Field Name | Type | Description | Default |
| --- | --- | --- | --- |
| fileId | string | **Required** File unique ID. | |
2019-11-21 07:51:55 +13:00
| read | array | An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. | |
| write | array | An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. | |
2019-08-29 00:37:13 +12:00
2019-05-09 18:54:39 +12:00
## Delete File
```http request
2019-10-09 17:16:38 +13:00
DELETE https://appwrite.io/v1/storage/files/{fileId}
2019-05-09 18:54:39 +12:00
```
2019-10-09 21:40:02 +13:00
** Delete a file by its unique ID. Only users with write permissions have access to delete this resource. **
2019-05-09 18:54:39 +12:00
### Parameters
| Field Name | Type | Description | Default |
| --- | --- | --- | --- |
| fileId | string | **Required** File unique ID. | |
2019-08-27 21:12:40 +12:00
## Get File for Download
2019-05-09 18:54:39 +12:00
```http request
2019-10-09 17:16:38 +13:00
GET https://appwrite.io/v1/storage/files/{fileId}/download
2019-05-09 18:54:39 +12:00
```
2019-10-09 21:40:02 +13:00
** Get file content by its unique ID. The endpoint response return with a 'Content-Disposition: attachment' header that tells the browser to start downloading the file to user downloads directory. **
2019-05-09 18:54:39 +12:00
### Parameters
| Field Name | Type | Description | Default |
| --- | --- | --- | --- |
| fileId | string | **Required** File unique ID. | |
2019-08-27 21:12:40 +12:00
## Get File Preview
2019-05-09 18:54:39 +12:00
```http request
2019-10-09 17:16:38 +13:00
GET https://appwrite.io/v1/storage/files/{fileId}/preview
2019-05-09 18:54:39 +12:00
```
2020-01-28 10:50:41 +13:00
** Get a file preview image. Currently, this method supports preview for image files (jpg, png, and gif), other supported formats, like pdf, docs, slides, and spreadsheets, will return the file icon image. You can also pass query string arguments for cutting and resizing your preview image. **
2019-05-09 18:54:39 +12:00
### Parameters
| Field Name | Type | Description | Default |
| --- | --- | --- | --- |
| fileId | string | **Required** File unique ID | |
2020-02-14 19:28:54 +13:00
| width | integer | Resize preview image width, Pass an integer between 0 to 4000. | 0 |
| height | integer | Resize preview image height, Pass an integer between 0 to 4000. | 0 |
| quality | integer | Preview image quality. Pass an integer between 0 to 100. Defaults to 100. | 100 |
2019-05-09 18:54:39 +12:00
| background | string | Preview image background color. Only works with transparent images (png). Use a valid HEX color, no # is needed for prefix. | |
2020-02-14 19:28:54 +13:00
| output | string | Output format type (jpeg, jpg, png, gif and webp). | |
2019-05-09 18:54:39 +12:00
2019-08-27 21:12:40 +12:00
## Get File for View
2019-05-09 18:54:39 +12:00
```http request
2019-10-09 17:16:38 +13:00
GET https://appwrite.io/v1/storage/files/{fileId}/view
2019-05-09 18:54:39 +12:00
```
2019-10-09 21:40:02 +13:00
** Get file content by its unique ID. This endpoint is similar to the download method but returns with no 'Content-Disposition: attachment' header. **
2019-05-09 18:54:39 +12:00
### Parameters
| Field Name | Type | Description | Default |
| --- | --- | --- | --- |
| fileId | string | **Required** File unique ID. | |
| as | string | Choose a file format to convert your file to. Currently you can only convert word and pdf files to pdf or txt. This option is currently experimental only, use at your own risk. | |