> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> 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`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - 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. <br />

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. <br />  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 | read-only: true | validation: maxLength 1000
        - name: displayName | type: string | description: File name as it appears in the Media Manager.  | validation: maxLength 255
        - name: parentFolderId | type: string | description: GUID of the file's parent folder.  | validation: maxLength 100
        - name: labels | type: array<string> | 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.  | validation: maxItems 100, maxLength 200
 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.  | read-only: true | validation: maxLength 1000
     - name: displayName | type: string | description: File name as it appears in the Media Manager.  | validation: maxLength 255
     - name: url | type: string | description: Static URL of the file.  | read-only: true | validation: format WEB_URL
     - name: parentFolderId | type: string | description: GUID of the file's parent folder.  | validation: maxLength 100
     - name: hash | type: string | description: File hash.  | read-only: true | validation: maxLength 100
     - name: sizeInBytes | type: string | description: Size of the uploaded file in bytes.  | read-only: true | validation: format DECIMAL_VALUE, decimalValue {"maxScale":0}
     - 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).  | read-only: true 
     - name: mediaType | type: MediaType | description: Media file type.  | read-only: true 
         - enum:
         -     UNKNOWN: Unknown media type.
         -     IMAGE: Image file, such as JPEG or PNG.
         -     VIDEO: Video file.
         -     AUDIO: Audio file.
         -     DOCUMENT: Document file, such as PDF.
         -     VECTOR: Vector image file, such as SVG.
         -     ARCHIVE: Archive file, such as ZIP.
         -     MODEL3D: 3D model file.
         -     OTHER: Any other file type.
     - name: media | type: FileMedia | description: Media-type-specific metadata, such as an image's dimensions or a video's available resolutions. The relevant property is populated according to the file's `mediaType`.  | read-only: true 
        - 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.  | read-only: true 
                 - name: width | type: integer | description: Original image width.  | read-only: true 
                 - name: altText | type: string | description: Image alt text.  
                 - name: filename | type: string | description: Image filename.  | read-only: true 
              - name: colors | type: Colors | description: Image colors.  
                 - name: prominent | type: Color | description: Main color of the image.  
                    - name: hex | type: string | description: HEX color.  | validation: format COLOR_HEX
                    - name: rgb | type: ColorRGB | description: RGB color.  
                       - name: r | type: integer | description: Red channel.  | validation: minimum 0, maximum 255, format int32
                       - name: g | type: integer | description: Green channel.  | validation: minimum 0, maximum 255, format int32
                       - name: b | type: integer | description: Blue channel.  | validation: minimum 0, maximum 255, format int32
                 - name: palette | type: array<Color> | description: Color palette of the image.  | validation: maxItems 100
              - name: faces | type: array<FaceRecognition> | description: Information about faces in the image. Use to crop images without cutting out faces.  | validation: maxItems 100
                 - 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  | read-only: true | validation: maxLength 300
           - name: video | type: VideoV2 | description: Information about the video.  
              - name: id | type: string | description: WixMedia GUID.  
              - name: resolutions | type: array<VideoResolution> | description: Available resolutions for the video, starting with the optimal resolution.  | read-only: true | validation: maxItems 100
                 - 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.  | read-only: true 
           - name: audio | type: AudioV2 | description: Information about the audio.  
              - name: id | type: string | description: WixMedia GUID.  | validation: maxLength 200
              - name: assets | type: array<Audio> | description: Audio formats available for this file.  | validation: maxItems 100
                 - name: id | type: string | description: WixMedia GUID.  
                 - name: url | type: string | description: Audio URL.  
                 - name: filename | type: string | description: Audio filename.  | read-only: true 
              - name: bitrate | type: integer | description: Audio bitrate.  | read-only: true | validation: minimum 0, format int32
              - name: format | type: string | description: Audio format.  | read-only: true | validation: maxLength 100
              - name: duration | type: integer | description: Audio duration in seconds.  | read-only: true | validation: minimum 0, format int32
              - name: sizeInBytes | type: string | description: Audio size in bytes.  | read-only: true | validation: format DECIMAL_VALUE, decimalValue {"maxScale":0}
           - 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).  | read-only: true | validation: format date-time
              - name: sizeInBytes | type: string | description: Archive size in bytes.  | validation: format DECIMAL_VALUE
              - 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).  | read-only: true | validation: format date-time
              - name: filename | type: string | description: 3D filename.  | read-only: true 
              - name: sizeInBytes | type: string | description: 3D size in bytes.  | read-only: true | validation: format DECIMAL_VALUE
     - name: operationStatus | type: OperationStatus | description: Status of the file that was uploaded.  | read-only: true 
         - 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.  | read-only: true | validation: format WEB_URL
     - name: thumbnailUrl | type: string | description: URL of the file's thumbnail.  | read-only: true | validation: format WEB_URL
     - name: labels | type: array<string> | 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.  | validation: maxItems 100, maxLength 200
     - name: createdDate | type: string | description: Date and time the file was created.  | read-only: true | validation: format date-time
     - name: updatedDate | type: string | description: Date and time the file was updated.  | read-only: true | validation: format date-time
     - name: siteId | type: string | description: The Wix site GUID where the media file is stored.  | read-only: true | validation: maxLength 100
     - name: state | type: State | description: State of the file.  | read-only: true 
         - 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: <AUTH>' \
  -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.media.files.updateFileDescriptor(file)
 Description: Updates a file. <br />  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 | read-only: true | validation: maxLength 1000
        - name: displayName | type: string | description: File name as it appears in the Media Manager.  | validation: maxLength 255
        - name: parentFolderId | type: string | description: GUID of the file's parent folder.  | validation: maxLength 100
        - name: labels | type: array<string> | 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.  | validation: maxItems 100, maxLength 200
 Return type: PROMISE<FileDescriptor>
  - name: _id | type: string | description: File GUID. Generated when a file is uploaded to the Media Manager.  | read-only: true | validation: maxLength 1000
  - name: displayName | type: string | description: File name as it appears in the Media Manager.  | validation: maxLength 255
  - name: url | type: string | description: Static URL of the file.  | read-only: true | validation: format WEB_URL
  - name: parentFolderId | type: string | description: GUID of the file's parent folder.  | validation: maxLength 100
  - name: hash | type: string | description: File hash.  | read-only: true | validation: maxLength 100
  - name: sizeInBytes | type: string | description: Size of the uploaded file in bytes.  | read-only: true | validation: format DECIMAL_VALUE, decimalValue {"maxScale":0}
  - 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).  | read-only: true 
  - name: mediaType | type: MediaType | description: Media file type.  | read-only: true 
     - enum:
     -     UNKNOWN: Unknown media type.
     -     IMAGE: Image file, such as JPEG or PNG.
     -     VIDEO: Video file.
     -     AUDIO: Audio file.
     -     DOCUMENT: Document file, such as PDF.
     -     VECTOR: Vector image file, such as SVG.
     -     ARCHIVE: Archive file, such as ZIP.
     -     MODEL3D: 3D model file.
     -     OTHER: Any other file type.
  - name: media | type: FileMedia | description: Media-type-specific metadata, such as an image's dimensions or a video's available resolutions. The relevant property is populated according to the file's `mediaType`.  | read-only: true 
     - 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.  | validation: format COLOR_HEX
                 - name: rgb | type: ColorRGB | description: RGB color.  
                    - name: r | type: integer | description: Red channel.  | validation: minimum 0, maximum 255, format int32
                    - name: g | type: integer | description: Green channel.  | validation: minimum 0, maximum 255, format int32
                    - name: b | type: integer | description: Blue channel.  | validation: minimum 0, maximum 255, format int32
              - name: palette | type: array<Color> | description: Color palette of the image.  | validation: maxItems 100
           - name: faces | type: array<FaceRecognition> | description: Information about faces in the image. Use to crop images without cutting out faces.  | validation: maxItems 100
              - 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  | read-only: true | validation: maxLength 300
        - 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.  | validation: maxLength 200
           - name: assets | type: array<string> | description: Audio formats available for this file.  | validation: maxItems 100
           - name: bitrate | type: integer | description: Audio bitrate.  | read-only: true | validation: minimum 0, format int32
           - name: format | type: string | description: Audio format.  | read-only: true | validation: maxLength 100
           - name: duration | type: integer | description: Audio duration in seconds.  | read-only: true | validation: minimum 0, format int32
           - name: sizeInBytes | type: string | description: Audio size in bytes.  | read-only: true | validation: format DECIMAL_VALUE, decimalValue {"maxScale":0}
        - 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).  | read-only: true 
           - name: sizeInBytes | type: string | description: Archive size in bytes.  | validation: format DECIMAL_VALUE
           - 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).  | read-only: true 
           - name: filename | type: string | description: 3D filename.  | read-only: true 
           - name: sizeInBytes | type: string | description: 3D size in bytes.  | read-only: true | validation: format DECIMAL_VALUE
  - name: operationStatus | type: OperationStatus | description: Status of the file that was uploaded.  | read-only: true 
     - 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.  | read-only: true | validation: format WEB_URL
  - name: thumbnailUrl | type: string | description: URL of the file's thumbnail.  | read-only: true | validation: format WEB_URL
  - name: labels | type: array<string> | 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.  | validation: maxItems 100, maxLength 200
  - name: _createdDate | type: Date | description: Date and time the file was created.  | read-only: true 
  - name: _updatedDate | type: Date | description: Date and time the file was updated.  | read-only: true 
  - name: siteId | type: string | description: The Wix site GUID where the media file is stored.  | read-only: true | validation: maxLength 100
  - name: state | type: State | description: State of the file.  | read-only: true 
     - 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-managed)
Self-managed 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);
};
```

---