Updates a file.
The updateFileDescriptor()
function returns a Promise that resolves to the updated file's descriptor.
You can use the parentFolderId
parameter to move a file from its current folder to a different folder.
This function requires elevated permissions and runs only on the backend and on dashboard pages.
function updateFileDescriptor(
file: FileDescriptor,
options: UpdateFileDescriptorOptions,
): Promise<FileDescriptor>;
The file to update.
import { files } from "wix-media.v2";
/* 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"
* }
*/
There is 1 error with this status code.
This method may also return standard errors. Learn more about standard Wix errors.