> Portal Navigation:
>
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt
# UpdateFileDescriptor
# Package: mediaManager
# Namespace: FilesService
# Method link: https://dev.wix.com/docs/api-reference/assets/media/media-manager/files/update-file-descriptor.md
## Permission Scopes:
Manage Media Manager: SCOPE.DC-MEDIA.MANAGE-MEDIAMANAGER
## Introduction
Updates a file.
Specify the `parentFolderId` parameter to move a file from its current folder to a different folder.
---
## REST API
### Schema
```
Method: updateFileDescriptor
Description: Updates a file. Specify the `parentFolderId` parameter to move a file from its current folder to a different folder.
URL: https://www.wixapis.com/site-media/v1/files/update-file-descriptor
Method: PATCH
# Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
Required parameters: file, file.id
Method parameters:
param name: file | type: FileDescriptor | required: true
- name: id | type: string | description: File GUID. Generated when a file is uploaded to the Media Manager. | required: true
- name: displayName | type: string | description: File name as it appears in the Media Manager.
- name: parentFolderId | type: string | description: GUID of the file's parent folder.
- name: labels | type: array | description: Labels assigned to media files that describe and categorize them. Provided by the Wix user, or generated by [Google Vision API](https://cloud.google.com/vision/docs/drag-and-drop) for images.
Return type: UpdateFileDescriptorResponse
- name: file | type: FileDescriptor | description: Information about the updated file.
- name: id | type: string | description: File GUID. Generated when a file is uploaded to the Media Manager.
- name: displayName | type: string | description: File name as it appears in the Media Manager.
- name: url | type: string | description: Static URL of the file.
- name: parentFolderId | type: string | description: GUID of the file's parent folder.
- name: hash | type: string | description: File hash.
- name: sizeInBytes | type: string | description: Size of the uploaded file in bytes.
- name: private | type: boolean | description: Whether the file is public or private. Learn more about [private files](https://dev.wix.com/docs/rest/assets/media/media-manager/files/private-files.md).
- name: mediaType | type: MediaType | description: Media file type.
- enum: UNKNOWN, IMAGE, VIDEO, AUDIO, DOCUMENT, VECTOR, ARCHIVE, MODEL3D, OTHER
- name: media | type: FileMedia | description: Media file content.
- ONE-OF:
- name: image | type: ImageMedia | description: Information about the image.
- name: image | type: Image | description: Image data.
- name: id | type: string | description: WixMedia image GUID.
- name: url | type: string | description: Image URL.
- name: height | type: integer | description: Original image height.
- name: width | type: integer | description: Original image width.
- name: altText | type: string | description: Image alt text.
- name: filename | type: string | description: Image filename.
- name: colors | type: Colors | description: Image colors.
- name: prominent | type: Color | description: Main color of the image.
- name: hex | type: string | description: HEX color.
- name: rgb | type: ColorRGB | description: RGB color.
- name: r | type: integer | description: Red channel.
- name: g | type: integer | description: Green channel.
- name: b | type: integer | description: Blue channel.
- name: palette | type: array | description: Color palette of the image.
- name: faces | type: array | description: Information about faces in the image. Use to crop images without cutting out faces.
- name: confidence | type: number | description: The accuracy percentage of the face recognition. The likelihood that a face is detected.
- name: x | type: integer | description: Top left x pixel coordinate of the face.
- name: y | type: integer | description: Top left y pixel coordinate of the face.
- name: height | type: integer | description: Face pixel height.
- name: width | type: integer | description: Face pixel width.
- name: previewImage | type: Image | description: Information about the image preview. You can use this to display a preview for private images.
- name: caption | type: string | description: Optional, An AI generated description of the image
- name: video | type: VideoV2 | description: Information about the video.
- name: id | type: string | description: WixMedia GUID.
- name: resolutions | type: array | description: Available resolutions for the video, starting with the optimal resolution.
- name: url | type: string | description: Video URL.
- name: height | type: integer | description: Video height.
- name: width | type: integer | description: Video width.
- name: format | type: string | description: Video format Possible values: ['144p.mp4' '144p.webm' '240p.mp4' '240p.webm' '360p.mp4' '360p.webm' '480p.mp4' '480p.webm' '720p.mp4' '720p.webm' '1080p.mp4' '1080p.webm', 'hls' ]
- name: filename | type: string | description: Video filename.
- name: audio | type: AudioV2 | description: Information about the audio.
- name: id | type: string | description: WixMedia GUID.
- name: assets | type: array | description: Audio formats available for this file.
- name: id | type: string | description: WixMedia GUID.
- name: url | type: string | description: Audio URL.
- name: filename | type: string | description: Audio filename.
- name: bitrate | type: integer | description: Audio bitrate.
- name: format | type: string | description: Audio format.
- name: duration | type: integer | description: Audio duration in seconds.
- name: sizeInBytes | type: string | description: Audio size in bytes.
- name: document | type: Document | description: Information about the document.
- name: id | type: string | description: WixMedia GUID.
- name: url | type: string | description: Document URL.
- name: filename | type: string | description: Document filename.
- name: vector | type: ImageMedia | description: Information about the vector.
- name: archive | type: Archive | description: Information about the archive.
- name: id | type: string | description: WixMedia GUID.
- name: url | type: string | description: Archive URL.
- name: urlExpirationDate | type: string | description: Archive URL expiration date (when relevant).
- name: sizeInBytes | type: string | description: Archive size in bytes.
- name: filename | type: string | description: Archive filename.
- name: model3d | type: Model3D | description: Information about the 3D Model.
- name: id | type: string | description: WixMedia 3D GUID.
- name: url | type: string | description: 3D URL.
- name: thumbnail | type: Image | description: 3D thumbnail Image
- name: altText | type: string | description: 3D alt text.
- name: urlExpirationDate | type: string | description: 3D URL expiration date (when relevant).
- name: filename | type: string | description: 3D filename.
- name: sizeInBytes | type: string | description: 3D size in bytes.
- name: operationStatus | type: OperationStatus | description: Status of the file that was uploaded.
- enum:
- FAILED: The file failed to upload, for example, during media post processing.
- READY: The file uploaded, finished all processing, and is ready for use.
- PENDING: The file is processing and the URLs are not yet available. This response is returned when importing a file.
- name: sourceUrl | type: string | description: URL where the file was uploaded from.
- name: thumbnailUrl | type: string | description: URL of the file's thumbnail.
- name: labels | type: array | description: Labels assigned to media files that describe and categorize them. Provided by the Wix user, or generated by [Google Vision API](https://cloud.google.com/vision/docs/drag-and-drop) for images.
- name: createdDate | type: string | description: Date and time the file was created.
- name: updatedDate | type: string | description: Date and time the file was updated.
- name: siteId | type: string | description: The Wix site GUID where the media file is stored.
- name: state | type: State | description: State of the file.
- enum:
- OK: File is ready for consumption
- DELETED: Deleted file
Possible Errors:
HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: FIELD_MASK_IS_EMPTY_OR_MISSING | Description: `fieldMask` is empty or missing from the request.
```
### Examples
### Update a file
```curl
curl -X PATCH \
'https://www.wixapis.com/site-media/v1/files/update-file-descriptor' \
-H 'Authorization: ' \
-H 'Content-Type: application/json' \
-d '{
"file": {
"id": "6acbb8_f968336b3fea4cbebc056d5c41f5944d~mv2.png",
"displayName": "New File Name",
"parentFolderId": "media-root",
"labels": ["image", "logo"]
}
}'
```
---
## JavaScript SDK
### Schema
```
Method: wixClientAdmin.mediaManager.FilesService.updateFileDescriptor(file)
Description: Updates a file. Specify the `parentFolderId` parameter to move a file from its current folder to a different folder.
# Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
Required parameters: file, file._id
Method parameters:
param name: file | type: FileDescriptor | required: true
- name: _id | type: string | description: File GUID. Generated when a file is uploaded to the Media Manager. | required: true
- name: displayName | type: string | description: File name as it appears in the Media Manager.
- name: parentFolderId | type: string | description: GUID of the file's parent folder.
- name: labels | type: array | description: Labels assigned to media files that describe and categorize them. Provided by the Wix user, or generated by [Google Vision API](https://cloud.google.com/vision/docs/drag-and-drop) for images.
Return type: PROMISE
- name: _id | type: string | description: File GUID. Generated when a file is uploaded to the Media Manager.
- name: displayName | type: string | description: File name as it appears in the Media Manager.
- name: url | type: string | description: Static URL of the file.
- name: parentFolderId | type: string | description: GUID of the file's parent folder.
- name: hash | type: string | description: File hash.
- name: sizeInBytes | type: string | description: Size of the uploaded file in bytes.
- name: private | type: boolean | description: Whether the file is public or private. Learn more about [private files](https://dev.wix.com/docs/rest/assets/media/media-manager/files/private-files.md).
- name: mediaType | type: MediaType | description: Media file type.
- enum: UNKNOWN, IMAGE, VIDEO, AUDIO, DOCUMENT, VECTOR, ARCHIVE, MODEL3D, OTHER
- name: media | type: FileMedia | description: Media file content.
- ONE-OF:
- name: image | type: ImageMedia | description: Information about the image.
- name: image | type: string | description: Image data.
- name: colors | type: Colors | description: Image colors.
- name: prominent | type: Color | description: Main color of the image.
- name: hex | type: string | description: HEX color.
- name: rgb | type: ColorRGB | description: RGB color.
- name: r | type: integer | description: Red channel.
- name: g | type: integer | description: Green channel.
- name: b | type: integer | description: Blue channel.
- name: palette | type: array | description: Color palette of the image.
- name: faces | type: array | description: Information about faces in the image. Use to crop images without cutting out faces.
- name: confidence | type: number | description: The accuracy percentage of the face recognition. The likelihood that a face is detected.
- name: x | type: integer | description: Top left x pixel coordinate of the face.
- name: y | type: integer | description: Top left y pixel coordinate of the face.
- name: height | type: integer | description: Face pixel height.
- name: width | type: integer | description: Face pixel width.
- name: previewImage | type: string | description: Information about the image preview. You can use this to display a preview for private images.
- name: caption | type: string | description: Optional, An AI generated description of the image
- name: video | type: string | description: Information about the video.
- name: audio | type: AudioV2 | description: Information about the audio.
- name: _id | type: string | description: WixMedia GUID.
- name: assets | type: array | description: Audio formats available for this file.
- name: bitrate | type: integer | description: Audio bitrate.
- name: format | type: string | description: Audio format.
- name: duration | type: integer | description: Audio duration in seconds.
- name: sizeInBytes | type: string | description: Audio size in bytes.
- name: document | type: string | description: Information about the document.
- name: vector | type: ImageMedia | description: Information about the vector.
- name: archive | type: Archive | description: Information about the archive.
- name: _id | type: string | description: WixMedia GUID.
- name: url | type: string | description: Archive URL.
- name: urlExpirationDate | type: Date | description: Archive URL expiration date (when relevant).
- name: sizeInBytes | type: string | description: Archive size in bytes.
- name: filename | type: string | description: Archive filename.
- name: model3d | type: Model3D | description: Information about the 3D Model.
- name: _id | type: string | description: WixMedia 3D GUID.
- name: url | type: string | description: 3D URL.
- name: thumbnail | type: string | description: 3D thumbnail Image
- name: altText | type: string | description: 3D alt text.
- name: urlExpirationDate | type: Date | description: 3D URL expiration date (when relevant).
- name: filename | type: string | description: 3D filename.
- name: sizeInBytes | type: string | description: 3D size in bytes.
- name: operationStatus | type: OperationStatus | description: Status of the file that was uploaded.
- enum:
- FAILED: The file failed to upload, for example, during media post processing.
- READY: The file uploaded, finished all processing, and is ready for use.
- PENDING: The file is processing and the URLs are not yet available. This response is returned when importing a file.
- name: sourceUrl | type: string | description: URL where the file was uploaded from.
- name: thumbnailUrl | type: string | description: URL of the file's thumbnail.
- name: labels | type: array | description: Labels assigned to media files that describe and categorize them. Provided by the Wix user, or generated by [Google Vision API](https://cloud.google.com/vision/docs/drag-and-drop) for images.
- name: _createdDate | type: Date | description: Date and time the file was created.
- name: _updatedDate | type: Date | description: Date and time the file was updated.
- name: siteId | type: string | description: The Wix site GUID where the media file is stored.
- name: state | type: State | description: State of the file.
- enum:
- OK: File is ready for consumption
- DELETED: Deleted file
Possible Errors:
HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: FIELD_MASK_IS_EMPTY_OR_MISSING | Description: `fieldMask` is empty or missing from the request.
```
### Examples
### Update a file's display name from visitor input (with $w)
This code uses the visitor's input on the page to update the display name of an image which they choose from a dropdown list on the page.
```javascript
/****************************************
* Backend code - update-file.web.js/ts *
***************************************/
import { Permissions, webMethod } from '@wix/web-methods';
import { files } from '@wix/media';
import { auth } from '@wix/essentials';
export const updateFile = webMethod(Permissions.Anyone, async (fileId, file) => {
try {
const elevatedUpdateFileDescriptor = auth.elevate(files.updateFileDescriptor);
const updatedDescriptor = await elevatedUpdateFileDescriptor({
_id: fileId,
...file
});
return updatedDescriptor;
} catch (error) {
console.error(error);
}
});
export const listImages = webMethod(Permissions.Anyone, async () => {
const listOptions = {
mediaTypes: ["IMAGE"]
}
try {
const elevatedListFiles = auth.elevate(files.listFiles)
const images = await elevatedListFiles(listOptions);
return images.files;
} catch (error) {
console.error(error);
}
});
/*************
* Page code *
************/
import { updateFile, listImages } from 'backend/update-file.web';
$w.onReady(async () => {
await populateImagesDropdown();
$w('#update').onClick(async () => {
const imageId = $w('#imagesDropdown').value;
const fileUpdates = {
displayName: $w('#newDisplayName').value
}
const updatedLocation = await updateFile(imageId, fileUpdates);
console.log('Display name successfully updated to:', updatedLocation.displayName)
$w('#updateSuccessMsg').show();
});
});
async function populateImagesDropdown() {
const images = await listImages();
const dropdownOptions = images.map((image) => {
return {
label: image.displayName,
value: image._id
};
});
$w('#imagesDropdown').options = dropdownOptions;
};
```
### Update a file's display name and labels (with elevated permissions)
```javascript
import { files } from '@wix/media';
import { auth } from '@wix/essentials';
/* Sample file value:
* {
* _id: 'd4dde1_0c8b26126ba94f3daee16d9e9be04f0c~mv2.jpg',
* displayName: 'river',
* labels: ['water', 'flowing', 'nature']
* }
*/
export async function myUpdateFileDescriptorFunction(file) {
try {
const elevatedUpdateFileDescriptor = auth.elevate(files.updateFileDescriptor);
const updatedDescriptor = await elevatedUpdateFileDescriptor(file);
console.log("Updated:", updatedDescriptor);
return updatedDescriptor;
} catch (error) {
console.error(error);
// Handle the error
}
}
/* Promise resolves to:
* {
* "_createdDate": "2023-08-09T08:45:50.000Z",
* "_id": "d4dde1_0c8b26126ba94f3daee16d9e9be04f0c~mv2.jpg",
* "_updatedDate": "2023-08-14T09:48:28.000Z",
* "displayName": "river",
* "hash": "2f2a61275002b90e6e8fa1be4674c4a7",
* "internalTags": [
* "_fileOrigin_uploaded"
* ],
* "labels": [
* "water",
* "flowing",
* "nature"
* ],
* "media": {
* "image": {
* "colors": {
* "palette": [
* {
* "rgb": {
* "b": 41,
* "g": 41,
* "r": 24
* }
* },
* {
* "rgb": {
* "b": 135,
* "g": 105,
* "r": 62
* }
* },
* {
* "rgb": {
* "b": 195,
* "g": 154,
* "r": 105
* }
* },
* {
* "rgb": {
* "b": 230,
* "g": 190,
* "r": 141
* }
* },
* {
* "rgb": {
* "b": 96,
* "g": 77,
* "r": 44
* }
* },
* {
* "rgb": {
* "b": 144,
* "g": 135,
* "r": 99
* }
* },
* {
* "rgb": {
* "b": 64,
* "g": 106,
* "r": 64
* }
* },
* {
* "rgb": {
* "b": 178,
* "g": 131,
* "r": 80
* }
* },
* {
* "rgb": {
* "b": 247,
* "g": 230,
* "r": 185
* }
* },
* {
* "rgb": {
* "b": 75,
* "g": 145,
* "r": 97
* }
* }
* ],
* "prominent": {
* "rgb": {
* "b": 41,
* "g": 41,
* "r": 24
* }
* }
* },
* "faces": [],
* "image": "wix:image://v1/d4dde1_0c8b26126ba94f3daee16d9e9be04f0c~mv2.jpg/river#originWidth=5760&originHeight=3840"
* }
* },
* "mediaType": "IMAGE",
* "operationStatus": "READY",
* "parentFolderId": "b2bc72834460412494c93617d88b8c89",
* "private": false,
* "siteId": "3ecba886-4267-11ee-be56-0242ac120002",
* "sizeInBytes": "3677628",
* "state": "OK",
* "thumbnailUrl": "https://static.wixstatic.com/media/d4dde1_0c8b26126ba94f3daee16d9e9be04f0c~mv2.jpg",
* "url": "https://static.wixstatic.com/media/d4dde1_0c8b26126ba94f3daee16d9e9be04f0c~mv2.jpg"
* }
*/
```
### Update a file's display name and labels
```javascript
import { files } from '@wix/media';
/* Sample file value:
* {
* _id: 'd4dde1_0c8b26126ba94f3daee16d9e9be04f0c~mv2.jpg',
* displayName: 'river',
* labels: ['water', 'flowing', 'nature']
* }
*/
export async function myUpdateFileDescriptorFunction(file) {
try {
const updatedDescriptor = await files.updateFileDescriptor(file);
console.log("Updated:", updatedDescriptor);
return updatedDescriptor;
} catch (error) {
console.error(error);
// Handle the error
}
}
/* Promise resolves to:
* {
* "_createdDate": "2023-08-09T08:45:50.000Z",
* "_id": "d4dde1_0c8b26126ba94f3daee16d9e9be04f0c~mv2.jpg",
* "_updatedDate": "2023-08-14T09:48:28.000Z",
* "displayName": "river",
* "hash": "2f2a61275002b90e6e8fa1be4674c4a7",
* "internalTags": [
* "_fileOrigin_uploaded"
* ],
* "labels": [
* "water",
* "flowing",
* "nature"
* ],
* "media": {
* "image": {
* "colors": {
* "palette": [
* {
* "rgb": {
* "b": 41,
* "g": 41,
* "r": 24
* }
* },
* {
* "rgb": {
* "b": 135,
* "g": 105,
* "r": 62
* }
* },
* {
* "rgb": {
* "b": 195,
* "g": 154,
* "r": 105
* }
* },
* {
* "rgb": {
* "b": 230,
* "g": 190,
* "r": 141
* }
* },
* {
* "rgb": {
* "b": 96,
* "g": 77,
* "r": 44
* }
* },
* {
* "rgb": {
* "b": 144,
* "g": 135,
* "r": 99
* }
* },
* {
* "rgb": {
* "b": 64,
* "g": 106,
* "r": 64
* }
* },
* {
* "rgb": {
* "b": 178,
* "g": 131,
* "r": 80
* }
* },
* {
* "rgb": {
* "b": 247,
* "g": 230,
* "r": 185
* }
* },
* {
* "rgb": {
* "b": 75,
* "g": 145,
* "r": 97
* }
* }
* ],
* "prominent": {
* "rgb": {
* "b": 41,
* "g": 41,
* "r": 24
* }
* }
* },
* "faces": [],
* "image": "wix:image://v1/d4dde1_0c8b26126ba94f3daee16d9e9be04f0c~mv2.jpg/river#originWidth=5760&originHeight=3840"
* }
* },
* "mediaType": "IMAGE",
* "operationStatus": "READY",
* "parentFolderId": "b2bc72834460412494c93617d88b8c89",
* "private": false,
* "siteId": "3ecba886-4267-11ee-be56-0242ac120002",
* "sizeInBytes": "3677628",
* "state": "OK",
* "thumbnailUrl": "https://static.wixstatic.com/media/d4dde1_0c8b26126ba94f3daee16d9e9be04f0c~mv2.jpg",
* "url": "https://static.wixstatic.com/media/d4dde1_0c8b26126ba94f3daee16d9e9be04f0c~mv2.jpg"
* }
*/
```
### Update a file's location (with elevated permissions)
```javascript
import { files } from '@wix/media';
import { auth } from '@wix/essentials';
/* Sample file value:
* {
* _id: 'd4dde1_0c8b26126ba94f3daee16d9e9be04f0c~mv2.jpg',
* parentFolderId: 'b2bc72834460412494c93617d88b8c89'
* }
*/
const elevatedUpdateFileDescriptor = auth.elevate(files.updateFileDescriptor);
async function myUpdateFileDescriptorFunction(file) {
try {
const updatedDescriptor = await elevatedUpdateFileDescriptor(file);
console.log("Updated:", updatedDescriptor);
return updatedDescriptor;
} catch (error) {
console.error(error);
// Handle the error
}
}
/* Promise resolves to:
* {
* "_createdDate": "2023-08-09T08:45:50.000Z",
* "_id": "d4dde1_0c8b26126ba94f3daee16d9e9be04f0c~mv2.jpg",
* "_updatedDate": "2023-09-10T09:53:50.000Z",
* "displayName": "river.jpg",
* "hash": "2f2a61275002b90e6e8fa1be4674c4a7",
* "internalTags": [
* "_fileOrigin_uploaded"
* ],
* "labels": [
* "mountain stream",
* "clear stream",
* "flowing water",
* "mountain torrent",
* "free-flowing",
* "streams",
* "running water",
* "downstream",
* "watercourse",
* "stream",
* "riverbed",
* "freshwater",
* "landscape photograph",
* "motion blur",
* "fresh water",
* "river bank",
* "torrent",
* "flow into",
* "landscape photography",
* "natural scenery"
* ],
* "media": {
* "image": {
* "colors": {
* "palette": [
* {
* "rgb": {
* "b": 41,
* "g": 41,
* "r": 24
* }
* },
* {
* "rgb": {
* "b": 135,
* "g": 105,
* "r": 62
* }
* },
* {
* "rgb": {
* "b": 195,
* "g": 154,
* "r": 105
* }
* },
* {
* "rgb": {
* "b": 230,
* "g": 190,
* "r": 141
* }
* },
* {
* "rgb": {
* "b": 96,
* "g": 77,
* "r": 44
* }
* },
* {
* "rgb": {
* "b": 144,
* "g": 135,
* "r": 99
* }
* },
* {
* "rgb": {
* "b": 64,
* "g": 106,
* "r": 64
* }
* },
* {
* "rgb": {
* "b": 178,
* "g": 131,
* "r": 80
* }
* },
* {
* "rgb": {
* "b": 247,
* "g": 230,
* "r": 185
* }
* },
* {
* "rgb": {
* "b": 75,
* "g": 145,
* "r": 97
* }
* }
* ],
* "prominent": {
* "rgb": {
* "b": 41,
* "g": 41,
* "r": 24
* }
* }
* },
* "faces": [],
* "image": "wix:image://v1/d4dde1_0c8b26126ba94f3daee16d9e9be04f0c~mv2.jpg/river.jpg#originWidth=5760&originHeight=3840"
* }
* },
* "mediaType": "IMAGE",
* "operationStatus": "READY",
* "parentFolderId": "b2bc72834460412494c93617d88b8c89",
* "private": false,
* "siteId": "3ecba886-4267-11ee-be56-0242ac120002",
* "sizeInBytes": "3677628",
* "state": "OK",
* "thumbnailUrl": "https://static.wixstatic.com/media/d4dde1_0c8b26126ba94f3daee16d9e9be04f0c~mv2.jpg",
* "url": "https://static.wixstatic.com/media/d4dde1_0c8b26126ba94f3daee16d9e9be04f0c~mv2.jpg"
* }
*/
```
### Update a file's location
```javascript
import { files } from '@wix/media';
/* Sample file value:
* {
* _id: 'd4dde1_0c8b26126ba94f3daee16d9e9be04f0c~mv2.jpg',
* parentFolderId: 'b2bc72834460412494c93617d88b8c89'
* }
*/
async function myUpdateFileDescriptorFunction(file) {
try {
const updatedDescriptor = await files.updateFileDescriptor(file);
console.log("Updated:", updatedDescriptor);
return updatedDescriptor;
} catch (error) {
console.error(error);
// Handle the error
}
}
/* Promise resolves to:
* {
* "_createdDate": "2023-08-09T08:45:50.000Z",
* "_id": "d4dde1_0c8b26126ba94f3daee16d9e9be04f0c~mv2.jpg",
* "_updatedDate": "2023-09-10T09:53:50.000Z",
* "displayName": "river.jpg",
* "hash": "2f2a61275002b90e6e8fa1be4674c4a7",
* "internalTags": [
* "_fileOrigin_uploaded"
* ],
* "labels": [
* "mountain stream",
* "clear stream",
* "flowing water",
* "mountain torrent",
* "free-flowing",
* "streams",
* "running water",
* "downstream",
* "watercourse",
* "stream",
* "riverbed",
* "freshwater",
* "landscape photograph",
* "motion blur",
* "fresh water",
* "river bank",
* "torrent",
* "flow into",
* "landscape photography",
* "natural scenery"
* ],
* "media": {
* "image": {
* "colors": {
* "palette": [
* {
* "rgb": {
* "b": 41,
* "g": 41,
* "r": 24
* }
* },
* {
* "rgb": {
* "b": 135,
* "g": 105,
* "r": 62
* }
* },
* {
* "rgb": {
* "b": 195,
* "g": 154,
* "r": 105
* }
* },
* {
* "rgb": {
* "b": 230,
* "g": 190,
* "r": 141
* }
* },
* {
* "rgb": {
* "b": 96,
* "g": 77,
* "r": 44
* }
* },
* {
* "rgb": {
* "b": 144,
* "g": 135,
* "r": 99
* }
* },
* {
* "rgb": {
* "b": 64,
* "g": 106,
* "r": 64
* }
* },
* {
* "rgb": {
* "b": 178,
* "g": 131,
* "r": 80
* }
* },
* {
* "rgb": {
* "b": 247,
* "g": 230,
* "r": 185
* }
* },
* {
* "rgb": {
* "b": 75,
* "g": 145,
* "r": 97
* }
* }
* ],
* "prominent": {
* "rgb": {
* "b": 41,
* "g": 41,
* "r": 24
* }
* }
* },
* "faces": [],
* "image": "wix:image://v1/d4dde1_0c8b26126ba94f3daee16d9e9be04f0c~mv2.jpg/river.jpg#originWidth=5760&originHeight=3840"
* }
* },
* "mediaType": "IMAGE",
* "operationStatus": "READY",
* "parentFolderId": "b2bc72834460412494c93617d88b8c89",
* "private": false,
* "siteId": "3ecba886-4267-11ee-be56-0242ac120002",
* "sizeInBytes": "3677628",
* "state": "OK",
* "thumbnailUrl": "https://static.wixstatic.com/media/d4dde1_0c8b26126ba94f3daee16d9e9be04f0c~mv2.jpg",
* "url": "https://static.wixstatic.com/media/d4dde1_0c8b26126ba94f3daee16d9e9be04f0c~mv2.jpg"
* }
*/
```
### updateFileDescriptor (self-hosted)
Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md).
```javascript
import { createClient } from '@wix/sdk';
import { files } from '@wix/media';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed
const myWixClient = createClient ({
modules: { files },
// Include the auth strategy and host as relevant
});
async function updateFileDescriptor(file) {
const response = await myWixClient.files.updateFileDescriptor(file);
};
```
---