The Files API allows you to manage files and generate file urls from your Media Manager.
With the Files API, you can:
To use the Files API, import { files }
from the wix-media.v2
module:
import { files } from "wix-media.v2";
Deletes the specified files from the Media Manager.
The bulkDeleteFiles()
function returns a Promise that resolves when the files are deleted.
The deleted files are moved to the Media Manager's trash bin (TRASH_ROOT
folder) unless permanently deleted. To permanently delete files, pass the permanent
parameter with the value true
. Permanently deleting files isn't reversible, so make sure that these files aren't being used in a site or in any other way as the files will no longer be accessible.
Notes:
bulkRestoreFilesFromTrashBin()
to restore files from the Media Manager's trash bin.This function requires elevated permissions and runs only on the backend and on dashboard pages.
function bulkDeleteFiles(
fileIds: Array<string>,
options: BulkDeleteFilesOptions,
): Promise<void>;
IDs of the files to move to the Media Manager's trash bin.
You can also pass the files' Wix media URLs. For example, ["wix:image://v1/0abec0_b291a9349a0b4da59067f76287e386fb~mv2.jpg/leon.jpg#originWidth=3024&originHeight=4032"]
.
Learn more in the File and Folder IDs article.
Options to use when deleting files.
import { files } from "wix-media.v2";
/* Sample fileIds value:
* [
* 'w8ide0_v12i2pi4549locqdfeb5yy5b8iyh39az.pdf',
* 'w8ide0_ye3x8yyf5izwe01ovn682pa76bzrrcyt.pdf'
* ]
*
* Sample options value:
* {
* permanent: true
* }
*/
async function myBulkDeleteFilesFunction(fileIds, options) {
try {
await files.bulkDeleteFiles(fileIds, options);
console.log("Permanently deleted files.");
return;
} catch (error) {
console.error(error);
// Handle the error
}
}
/* Promise resolves to void */
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
Imports a bulk of files to the Media Manager using external urls.
The bulkImportFile()
function returns a Promise that resolves to an object containing bulk import metadata and an array of imported files' descriptors and metadata.
Returns information about the imported files. Use the parentFolderId
and filePath
parameters to specify in which folder you want each file to be imported.
If no folder is specified, the file is imported to the media-root
folder.
Note: When you import a file, it's not immediately available, meaning you can't manage or use the file straight away. Learn more about knowing when a file is ready.
To import files, you need to do one of the following for each file:
mimeType
field of the request. For example, mimeType: 'image/jpeg'
.displayName
or url
field of the request. For example, displayName: 'Example Image.jpeg
or url: https://www.example.com/image.jpeg
.Note: If you want to validate the media type, pass the file's expected media type in the optional mediaType
field of the request. For example, mediaType: 'IMAGE'
.
This function requires elevated permissions and runs only on the backend and on dashboard pages.
function bulkImportFile(
importFileRequests: Array<ImportFileRequest>,
options: BulkImportFileOptions,
): Promise<BulkImportFileResponse>;
Information about the files to import.
Options to include the file descriptor in the response.
import { files } from "wix-media.v2";
/* Sample importFileRequests value:
* [
* {
* displayName: 'image1',
* mediaType: 'IMAGE',
* mimeType: 'image/jpeg',
* parentFolderId: 'igje5u22nij3qkltzsnol37j3dnthvvh',
* url: 'https://www.site1.com/example.jpg'
* },
* {
* displayName: 'vectorArt1',
* mediaType: 'VECTOR',
* labels : ['label1', 'label2'],
* url: 'https://cdn.vectorstock.com/example-vector-art.webp'
* },
* {
* displayName: 'video1',
* mediaType: 'VIDEO',
* url: 'https://cdn.pixabay.com/example-video.mp4'
* }
* ]
*/
async function mybulkImportFileFunction(importFileRequests) {
try {
const importedFiles = await files.bulkImportFile(importFileRequests);
console.log("Imported files:", importedFiles);
return importedFiles;
} catch (error) {
console.error(error);
// Handle the error
}
}
/* Promise resolves to:
* {
* "bulkActionMetadata": {
* "totalFailures": 0,
* "totalSuccesses": 3,
* "undetailedFailures": 0
* },
* "results": [
* {
* "item": {
* "_createdDate": "2023-12-26T10:22:31.000Z",
* "_id": "a8a52b_f8c86723942347488316f1ab35119411~mv2.jpg",
* "_updatedDate": "2023-12-26T10:22:31.000Z",
* "addedBy": {
* "identityId": "a8a52bb9-bac0-4bba-a55c-0611b5cdaa16",
* "identityType": "MEMBER"
* },
* "displayName": "image1.jpg",
* "hash": "",
* "internalTags": [],
* "labels": [],
* "mediaType": "IMAGE",
* "operationStatus": "PENDING",
* "parentFolderId": "igje5u22nij3qkltzsnol37j3dnthvvh",
* "private": false,
* "siteId": "49dcb500-1081-47b0-b13b-368b9bed8fa9",
* "sizeInBytes": "-1",
* "sourceUrl": "https://www.site1.com/example.jpg",
* "state": "OK",
* "thumbnailUrl": "https://static.wixstatic.com/media/a8a52b_f8c86723942347488316f1ab35119411~mv2.jpg",
* "url": "https://static.wixstatic.com/media/a8a52b_f8c86723942347488316f1ab35119411~mv2.jpg"
* },
* "itemMetadata": {
* "_id": "a8a52b_f8c86723942347488316f1ab35119411~mv2.jpg",
* "originalIndex": 0,
* "success": true
* }
* },
* {
* "item": {
* "_createdDate": "2023-12-26T10:22:32.000Z",
* "_id": "a8a52b_43eb6841371f4d738ddfcb7fa2bb62be-tmp.svg",
* "_updatedDate": "2023-12-26T10:22:32.000Z",
* "addedBy": {
* "identityId": "a8a52bb9-bac0-4bba-a55c-0611b5cdaa16",
* "identityType": "MEMBER"
* },
* "displayName": "vectorArt1.webp.svg",
* "hash": "",
* "internalTags": [],
* "labels": ["label1", "label2"],
* "mediaType": "VECTOR",
* "operationStatus": "PENDING",
* "parentFolderId": "media-root",
* "private": false,
* "siteId": "49dcb500-1081-47b0-b13b-368b9bed8fa9",
* "sizeInBytes": "-1",
* "sourceUrl": "https://cdn.vectorstock.com/example-vector-art.webp",
* "state": "OK",
* "thumbnailUrl": "https://static.wixstatic.com/shapes/a8a52b_43eb6841371f4d738ddfcb7fa2bb62be-tmp.svg",
* "url": "https://static.wixstatic.com/shapes/a8a52b_43eb6841371f4d738ddfcb7fa2bb62be-tmp.svg"
* },
* "itemMetadata": {
* "_id": "a8a52b_43eb6841371f4d738ddfcb7fa2bb62be-tmp.svg",
* "originalIndex": 1,
* "success": true
* }
* },
* {
* "item": {
* "_createdDate": "2023-12-26T10:22:32.000Z",
* "_id": "a8a52b_fec67a695b474a729e3a31010afbb0af",
* "_updatedDate": "2023-12-26T10:22:32.000Z",
* "addedBy": {
* "identityId": "a8a52bb9-bac0-4bba-a55c-0611b5cdaa16",
* "identityType": "MEMBER"
* },
* "displayName": "video1.mp4",
* "hash": "",
* "internalTags": [],
* "labels": [],
* "mediaType": "VIDEO",
* "operationStatus": "PENDING",
* "parentFolderId": "media-root",
* "private": false,
* "siteId": "49dcb500-1081-47b0-b13b-368b9bed8fa9",
* "sizeInBytes": "-1",
* "sourceUrl": "https://cdn.pixabay.com/example-video.mp4",
* "state": "OK",
* "thumbnailUrl": "https://static.wixstatic.com/media/54ece48fa04e492fa46bd79980105f0d.png",
* "url": "https://video.wixstatic.com/video/a8a52b_fec67a695b474a729e3a31010afbb0af/file"
* },
* "itemMetadata": {
* "_id": "a8a52b_fec67a695b474a729e3a31010afbb0af",
* "originalIndex": 2,
* "success": true
* }
* }
* ]
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
This method has been replaced with Bulk Import File, and will be removed on March 31, 2024.
Deprecated.
This function has been replaced with bulkImportFile()
, and will be removed on March 31, 2024.
The bulkImportFiles()
function returns a Promise that resolves to an array of the imported files' descriptors.
Imports a bulk of files to the Media Manager using external urls.
Returns information about the imported files. Use the parentFolderId
and filePath
parameters to specify in which folder you want each file to be imported.
If no folder is specified, the file is imported to the media-root
folder.
Note: The media
property isn't returned in the files
response object.
To import files, you need to do one of the following for each file:
mimeType
field of the request. For example, mimeType: 'image/jpeg'
.displayName
or url
field of the request. For example, displayName: 'Example Image.jpeg
or url: https://www.example.com/image.jpeg
.Note: If you want to validate the media type, pass the file's expected media type in the optional mediaType
field of the request. For example, mediaType: 'IMAGE'
.
This function requires elevated permissions and runs only on the backend and on dashboard pages.
function bulkImportFiles(
importFileRequests: Array<ImportFileRequest>,
): Promise<BulkImportFilesResponse>;
Information about the files to import.
import { files } from "wix-media.v2";
/* Sample importFileRequests value:
* [
* {
* displayName: 'image1',
* mediaType: 'IMAGE',
* mimeType: 'image/jpeg',
* parentFolderId: 'igje5u22nij3qkltzsnol37j3dnthvvh',
* url: 'https://www.site1.com/example.jpg'
* },
* {
* displayName: 'vectorArt1',
* mediaType: 'VECTOR',
* labels : ['label1', 'label2'],
* url: 'https://cdn.vectorstock.com/example-vector-art.webp'
* },
* {
* displayName: 'video1',
* mediaType: 'VIDEO'
* url: 'https://cdn.pixabay.com/example-video.mp4',
* }
* ]
*/
async function myBulkImportFilesFunction(importFileRequests) {
try {
const importedFiles = await files.bulkImportFiles(importFileRequests);
console.log("Imported files:", importedFiles);
return importedFiles;
} catch (error) {
console.error(error);
// Handle the error
}
}
/* Promise resolves to:
* {
* "files": [
* {
* "_createdDate": "2023-07-23T12:15:49.000Z",
* "_id": "w8ide0_h8bpmhc3j3qhgncce0et1nnkghsfozl2~mv2.jpg",
* "_updatedDate": "2023-07-23T12:15:49.000Z",
* "displayName": "image1.jpg",
* "hash": "",
* "internalTags": [],
* "labels": [],
* "mediaType": "IMAGE",
* "operationStatus": "PENDING",
* "parentFolderId": "igje5u22nij3qkltzsnol37j3dnthvvh",
* "private": false,
* "siteId": "3ecba886-4267-11ee-be56-0242ac120002",
* "sizeInBytes": "-1",
* "sourceUrl": "https://www.site1.com/example.jpg",
* "state": "OK",
* "thumbnailUrl": "https://static.wixstatic.com/media/w8ide0_h8bpmhc3j3qhgncce0et1nnkghsfozl2~mv2.jpg",
* "url": "https://static.wixstatic.com/media/w8ide0_h8bpmhc3j3qhgncce0et1nnkghsfozl2~mv2.jpg"
* },
* {
* "_createdDate": "2023-07-23T12:15:50.000Z",
* "_id": "w8ide0_e9xsr959r1ze5aavswj2978r6jt05bwl-tmp.svg",
* "_updatedDate": "2023-07-23T12:15:50.000Z",
* "displayName": "vectorArt1.webp.svg",
* "hash": "",
* "internalTags": [],
* "labels": [
* "label1",
* "label2"
* ],
* "mediaType": "VECTOR",
* "operationStatus": "PENDING",
* "parentFolderId": "media-root",
* "private": false,
* "siteId": "3ecba886-4267-11ee-be56-0242ac120002",
* "sizeInBytes": "20532",
* "sourceUrl": "https://cdn.vectorstock.com/example-vector-art.webp",
* "state": "OK",
* "thumbnailUrl": "https://static.wixstatic.com/shapes/w8ide0_e9xsr959r1ze5aavswj2978r6jt05bwl-tmp.svg",
* "url": "https://static.wixstatic.com/shapes/w8ide0_e9xsr959r1ze5aavswj2978r6jt05bwl-tmp.svg"
* },
* {
* "_createdDate": "2023-07-23T12:15:50.000Z",
* "_id": "w8ide0_f6e8f09e5055432286db483917ba923e",
* "_updatedDate": "2023-07-23T12:15:50.000Z",
* "displayName": "video1.mp4",
* "hash": "",
* "internalTags": [],
* "labels": [],
* "mediaType": "VIDEO",
* "operationStatus": "PENDING",
* "parentFolderId": "media-root",
* "private": false,
* "siteId": "3ecba886-4267-11ee-be56-0242ac120002",
* "sizeInBytes": "-1",
* "sourceUrl": "https://cdn.pixabay.com/example-video.mp4",
* "state": "OK",
* "thumbnailUrl": "https://static.wixstatic.com/media/yibv80byru0wei9ficri8fd8o1rghueu.png",
* "url": "https://video.wixstatic.com/video/w8ide0_f6e8f09e5055432286db483917ba923e/file"
* }
* ]
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
Restores the specified files from the Media Manager's trash bin, and moves them to their original locations in the Media Manager.
The bulkRestoreFilesFromTrashBin()
function returns a Promise that resolves when the files have been restored.
This function requires elevated permissions and runs only on the backend and on dashboard pages.
function bulkRestoreFilesFromTrashBin(fileIds: Array<string>): Promise<void>;
IDs of the files to restore from the Media Manager's trash bin.
You can also pass the files' Wix media URLs. For example, ["wix:image://v1/0abec0_b291a9349a0b4da59067f76287e386fb~mv2.jpg/leon.jpg#originWidth=3024&originHeight=4032"]
.
Learn more in the File and Folder IDs article.
import { files } from "wix-media.v2";
/* Sample fileIds value:
* [
* 'd4dde1_dee18c9ada174a818ccf75c50e72c739~mv2.jpg',
* 'd4dde1_32288e20a5aa4213a52b15426fb27c9f~mv2.png',
* 'd4dde1_8dd2bfe6121f43b29ebeaa63988abf54.svg'
* ]
*/
async function myBulkRestoreFilesFromTrashBinFunction(fileIds) {
try {
const restoredFiles = await files.bulkRestoreFilesFromTrashBin(fileIds);
console.log("Restored Files:", restoredFiles);
return restoredFiles;
} catch (error) {
console.error(error);
}
}
/* Promise resolves to void */
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
Generates one or more temporary URLs for downloading a specific file in the Media Manager.
The generateFileDownloadUrl()
function returns a Promise that resolves to an array containing download URLs for the assets specified in the options parameter.
To download different assets of the file, use the assetKeys
parameter which generates a download URL for each asset.
If no asset key is specified, it defaults to src
, which generates one download URL in the original file's format and quality.
Use this function to grant external clients access to a private media file. Use the expirationInMinutes
parameter to set the URL expiration time, and the expirationRedirectUrl
parameter to add a redirect URL when the URL expires.
To generate a permanent URL for downloading a compressed file that contains multiple files in the Media Manager, use the generateFilesDownloadUrl()
function.
Since this is a permanent URL, it is less secure. Therefore, to download private files, use the generateFileDownloadUrl()
function for each private file that you want to generate a download URL for.
This function requires elevated permissions and runs only on the backend and on dashboard pages.
function generateFileDownloadUrl(
fileId: string,
options: GenerateFileDownloadUrlOptions,
): Promise<GenerateFileDownloadUrlResponse>;
File ID.
You can also pass the files' Wix media URLs. For example, ["wix:image://v1/0abec0_b291a9349a0b4da59067f76287e386fb~mv2.jpg/leon.jpg#originWidth=3024&originHeight=4032"]
.
Learn more in the File and Folder IDs article.
Options to use when generating a file's download URL.
import { files } from "wix-media.v2";
/* Sample fileId value: 'd4dde1_dee18c9ada174a818ccf75c50e72c739~mv2.jpg' */
async function myGenerateFileDownloadUrlFunction(fileId) {
try {
const result = await files.generateFileDownloadUrl(fileId);
return result;
} catch (error) {
console.error(error);
// Handle the error
}
}
/* Promise resolves to:
* {
* "downloadUrls": [
* {
* "assetKey": "src",
* "url": "https://download-files.wixmp.com/media/d4dde1_dee18c9ada174a818ccf75c50e72c739~mv2.jpg?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ1cm46YXBwOmU2NjYzMGU3MTRmMDQ5MGFhZWExZjE0OWIzYjY5ZTMyIiwic3ViIjoidXJuOmFwcDplNjY2MzBlNzE0ZjA0OTBhYWVhMWYxNDliM2I2OWUzMiIsImF1ZCI6WyJ1cm46c2VydmljZTpmaWxlLmRvd25sb2FkIl0sImlhdCI6MTY5MjAyMTMxNSwiZXhwIjoxNjkyMDU3MzI1LCJqdGkiOiJjZTA1MzUxYy1jNDA4LTRlYmMtYWI0OC04MWM0NWJlZDlkM2IiLCJvYmoiOltbeyJwYXRoIjoiL21lZGlhL2Q0ZGRlMV9kZWUxOGM5YWRhMTc0YTgxOGNjZjc1YzUwZTcyYzczOX5tdjIuanBnIn1dXSwiZGlzIjp7ImZpbGVuYW1lIjoibmVvbS1BZGtKLUxncFRyRS11bnNwbGFzaC5qcGciLCJ0eXBlIjoiYXR0YWNobWVudCJ9fQ.HfZiuG7UFavOpgh2T0lVn56oZ9NpLoV3z9Gmnqptt8Y"
* }
* ]
* }
*/
There is 1 error with this status code.
This method may also return standard errors. Learn more about standard Wix errors.
Generates a resumable upload URL to allow external clients to upload large files over 10MB to the Media Manager.
The generateFileResumableUploadUrl()
function returns a Promise that resolves to an upload URL, token, and protocol.
When using the resumable upload URL, any interruptions will pause the file upload process, which automatically resumes once the interruption is resolved. The resumable upload URL is also helpful when network connection is poor.
To learn how external clients can use the generated upload URL in the response to upload large files to the Media Manager, see the Resumable Upload API article.
Note: When you upload a file, it's not immediately available, meaning you can't manage or use the file straight away. Learn more about knowing when a file is ready.
This function requires elevated permissions and runs only on the backend and on dashboard pages.
function generateFileResumableUploadUrl(
mimeType: string,
options: GenerateFileResumableUploadUrlOptions,
): Promise<GenerateFileResumableUploadUrlResponse>;
File mime type.
Options to use when generating a resumable upload URL.
import { files } from "wix-media.v2";
/* Sample mimeType value: 'image/jpeg'
*
* Sample options value:
* {
* fileName: 'image1.jpeg',
* parentFolderId: '103601562ec94214bee61f470b403dd5',
* labels: ['nature', 'outdoors']
* }
*/
async function myGenerateFileResumableUploadUrlFunction(mimeType, options) {
try {
const result = await files.generateFileResumableUploadUrl(
mimeType,
options,
);
return result;
} catch (error) {
console.error(error);
// Handle the error
}
}
/* Promise resolves to:
* {
* "uploadProtocol": "TUS",
* "uploadToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGk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load.wixmp.com/upload/tus"
* }
*/
There are 4 errors with this status code.
This method may also return standard errors. Learn more about standard Wix errors.
Generates an upload URL to allow external clients to upload a file to the Media Manager.
The generateFileUploadUrl()
function returns a Promise that resolves to an upload URL.
To learn how external clients can use the generated upload URL in the response to upload a file to the Media Manager, see the Upload API article.
Notes:
generateFileResumableUploadUrl()
instead. With the resumable upload URL, any interruption in the upload process pauses the file upload, and resumes the file upload process after the interruption.This function requires elevated permissions and runs only on the backend and on dashboard pages.
function generateFileUploadUrl(
mimeType: string,
options: GenerateFileUploadUrlOptions,
): Promise<GenerateFileUploadUrlResponse>;
File mime type.
Options to use when generating a file's upload URL.
import { files } from "wix-media.v2";
/* Sample mimeType value: 'image/jpeg'
* Sample options value:
* {
* fileName: 'image1.jpeg',
* parentFolderId: '103601562ec94214bee61f470b403dd5',
* labels: ['nature', 'outdoors']
* }
*/
async function myGenerateFileUploadUrlFunction(mimeType, options) {
try {
const result = await files.generateFileUploadUrl(mimeType, options);
const url = result.uploadUrl;
return url;
} catch (error) {
console.error(error);
// Handle the error
}
}
/* Promise resolves to:
* {
* "uploadUrl": "https://upload.wixmp.com/upload/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIzYTk0N2E5Ni01ZmFiLTQ0NjAtODVkNS1hNTIxNWRjNzRiMjEiLCJhdWQiOiJ1cm46c2VydmljZTp1cGxvYWQiLCJpc3MiOiJ1cm46c2VydmljZTp1cGxvYWQiLCJleHAiOjE2OTM5MTk3MjksImlhdCI6MTY5MzgzMzMxOSwiYnVja2V0IjoidXBsb2FkLXRtcC13aXhtcC1jZGZjMzg0ZjE1ODQxYWFhNWVhYjE2YjEiLCJwYXRoIjoibWVkaWEvZDRkZGUxXzE4Nzk3M2ZhYWRmNjQ3MGM4OTRhN2JjNmMyNjA2Yjkzfm12Mi5qcGVnIiwiY2FsbGJhY2tVcmwiOiJodHRwczovL3dpeG1wLWNkZmMzODRmMTU4NDFhYWE1ZWFiMTZiMS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VrOUluMHNJbWhsWVdSbGNuTWlPbTUxYkd3c0luQmhjM04wYUhKdmRXZG9JanAwY25WbGZYMC5iRWJSTzdnYkQxaXR0TW9Hb29QUTBsbDZrbW5jSEdfc05pRjRXZzFZWTc0IiwiYWNsIjoicHVibGljIiwibWltZVR5cGUiOiJpbWFnZS9qcGVnIn0.pd9ZssMw0NOTIxmNm0gm3r5WP6ySCy4vBxlT8ufU_Vw"
* }
*/
There are 5 errors with this status code.
This method may also return standard errors. Learn more about standard Wix errors.
Generates a URL for downloading a compressed file containing specific files in the Media Manager.
The generateFilesDownloadUrl()
function returns a Promise that resolves to a download URL.
The compressed file can contain up to 1000 files.
To generate one or more temporary URLs for downloading a specific file in the Media Manager, use the generateFileDownloadUrl()
function.
You can use the expirationInMinutes
parameter to set the URL expiration time, making it more secure than the generateFilesDownloadUrl()
function.
Therefore, to download private files, use the generateFileDownloadUrl
function for each private file that you want to generate a download URL for.
This function requires elevated permissions and runs only on the backend and on dashboard pages.
function generateFilesDownloadUrl(
fileIds: Array<string>,
): Promise<GenerateFilesDownloadUrlResponse>;
IDs of the files to download.
You can also pass the files' Wix media URLs. For example, ["wix:image://v1/0abec0_b291a9349a0b4da59067f76287e386fb~mv2.jpg/leon.jpg#originWidth=3024&originHeight=4032"]
.
Learn more in the File and Folder IDs article.
import { files } from "wix-media.v2";
/* Sample fileIds value:
* [
* 'd4dde1_dee18c9ada174a818ccf75c50e72c739~mv2.jpg',
* 'd4dde1_84a62b7aeb874f73a7b736cad663d6f2.pdf',
* 'd4dde1_e26da94b5cb440649ede0c433425449c~mv2.jpg'
* ]
*/
async function myGenerateFilesDownloadUrlFunction(fileIds) {
try {
const generatedUrl = await files.generateFilesDownloadUrl(fileIds);
const url = generatedUrl.downloadUrl;
return url;
} catch (error) {
console.error(error);
// Handle the error
}
}
/* Promise resolves to:
* {
* "downloadUrl": "https://archive.wixmp.com/archive/wix/38f69e35c283495187e85be0c8c06caf"
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
Generates a URL for streaming a specific video file in the Media Manager.
The generateVideoStreamingUrl()
function returns a Promise that resolves to a download URL and its asset key.
To stream different assets of the file, use the assetKeys
parameter which generates a video streaming URL for each asset. If no asset key is specified, it defaults to src
, which generates one video streaming URL in the original file's format and quality.
This function requires elevated permissions and runs only on the backend and on dashboard pages.
function generateVideoStreamingUrl(
fileId: string,
options: GenerateVideoStreamingUrlOptions,
): Promise<GenerateVideoStreamingUrlResponse>;
File ID.
You can also pass the files' Wix media URLs. For example, ["wix:image://v1/0abec0_b291a9349a0b4da59067f76287e386fb~mv2.jpg/leon.jpg#originWidth=3024&originHeight=4032"]
.
Learn more in the File and Folder IDs article.
Options to use when generating a video file's streaming URL.
import { files } from "wix-media.v2";
/* Sample ID value: 'd4dde1_6ce66a7e99db49f5964ef9f3ef97eefc'
*
* Sample options value:
* {
* format: 'HLS'
* }
*/
async function myGenerateVideoStreamingUrlFunction(fileId, options) {
try {
const streamingUrl = await files.generateVideoStreamingUrl(fileId, options);
return streamingUrl;
} catch (error) {
console.error(error);
// Handle the error
}
}
/* Promise resolves to:
* {
* "downloadUrl": {
* "assetKey": "HLS",
* "url": "https://repackager.wixmp.com/video.wixstatic.com/video/d4dde1_6ce66a7e99db49f5964ef9f3ef97eefc/,720p,360p,1080p,480p,/mp4/file.mp4.urlset/master.m3u8"
* }
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
Gets information about the specified file in the Media Manager.
The getFileDescriptor()
function returns a Promise that resolves to the specified file's descriptor.
Use getFileDescriptors()
to get multiple file descriptors at once.
This function requires elevated permissions and runs only on the backend and on dashboard pages.
function getFileDescriptor(fileId: string): Promise<FileDescriptor>;
File ID.
You can also pass the files' Wix media URLs. For example, ["wix:image://v1/0abec0_b291a9349a0b4da59067f76287e386fb~mv2.jpg/leon.jpg#originWidth=3024&originHeight=4032"]
.
Learn more in the File and Folder IDs article.
import { files } from "wix-media.v2";
/* Sample fileId value: 'w8ide0_989yy3iic89mi8880kq9jkr9x7nxiz7l~mv2.jpg' */
async function myGetFileDescriptorFunction(fileId) {
try {
const descriptor = await files.getFileDescriptor(fileId);
console.log("Retrieved descriptor:", descriptor);
return descriptor;
} catch (error) {
console.error(error);
// Handle the error
}
}
/* Promise resolves to:
* {
* "_createdDate": "2023-07-23T10:33:00.000Z",
* "_id": "w8ide0_989yy3iic89mi8880kq9jkr9x7nxiz7l~mv2.jpg",
* "_updatedDate": "2023-07-23T10:33:00.000Z",
* "displayName": "example.jpg",
* "hash": "x5bq2o4p8fj68xqt25v49wdnasys04xe",
* "internalTags": [],
* "labels": [],
* "media": {
* "image": {
* "faces": [],
* "image": "wix:image://v1/w8ide0_989yy3iic89mi8880kq9jkr9x7nxiz7l~mv2.jpg/example.jpg"
* }
* },
* "mediaType": "IMAGE",
* "operationStatus": "READY",
* "parentFolderId": "igje5u22nij3qkltzsnol37j3dnthvvh",
* "private": false,
* "siteId": "3ecba886-4267-11ee-be56-0242ac120002",
* "sizeInBytes": "47177",
* "sourceUrl": "https://example.org/filename.jpg",
* "state": "OK",
* "thumbnailUrl": "https://static.wixstatic.com/media/w8ide0_989yy3iic89mi8880kq9jkr9x7nxiz7l~mv2.jpg",
* "url": "https://static.wixstatic.com/media/w8ide0_989yy3iic89mi8880kq9jkr9x7nxiz7l~mv2.jpg"
* }
*/
There is 1 error with this status code.
This method may also return standard errors. Learn more about standard Wix errors.
Gets information about the specified files in the Media Manager.
The getFileDescriptors()
function returns a Promise that resolves to an array containing the specified files' descriptors.
Use getFileDescriptor()
to get a single file descriptor.
This function requires elevated permissions and runs only on the backend and on dashboard pages.
function getFileDescriptors(
fileIds: Array<string>,
): Promise<GetFileDescriptorsResponse>;
File IDs.
You can also pass the files' Wix media URLs. For example, ["wix:image://v1/0abec0_b291a9349a0b4da59067f76287e386fb~mv2.jpg/leon.jpg#originWidth=3024&originHeight=4032"]
.
Learn more in the File and Folder IDs article.
import { files } from "wix-media.v2";
/* Sample fileIds value:
* [
* 'w8ide0_87051wjiadg6qj2ywxb07vn5snqxxp2q',
* 'w8ide0_mnk3lozhxu0w4f1g5wuusmwqedox2w1p~mv2.jpg',
* 'w8ide0_578uul37zvr7b6d7ji3cbm91rlf5dvjy.zip'
* ]
*/
async function myGetFileDescriptorsFunction(fileIds) {
try {
const descriptors = await files.getFileDescriptors(fileIds);
console.log("Retrieved descriptors:", descriptors);
return descriptors;
} catch (error) {
console.error(error);
// Handle the error
}
}
/* Promise resolves to:
* {
* "files": [
* {
* "_createdDate": "2023-07-23T09:05:12.000Z",
* "_id": "w8ide0_mnk3lozhxu0w4f1g5wuusmwqedox2w1p~mv2.jpg",
* "_updatedDate": "2023-07-23T09:05:12.000Z",
* "displayName": "image1.jpg",
* "hash": "d7ltmbrrmdspiyrw3db29bpi1g8lsacz",
* "internalTags": [],
* "labels": [],
* "media": {
* "image": {
* "faces": [],
* "image": "wix:image://v1/w8ide0_mnk3lozhxu0w4f1g5wuusmwqedox2w1p~mv2.jpg/image1.jpg#originWidth=1000&originHeight=714"
* }
* },
* "mediaType": "IMAGE",
* "operationStatus": "READY",
* "parentFolderId": "media-root",
* "private": false,
* "siteId": "3ecba886-4267-11ee-be56-0242ac120002",
* "sizeInBytes": "112689",
* "sourceUrl": "https://website.org/image1.jpg",
* "state": "OK",
* "thumbnailUrl": "https://static.wixstatic.com/media/w8ide0_mnk3lozhxu0w4f1g5wuusmwqedox2w1p~mv2.jpg",
* "url": "https://static.wixstatic.com/media/w8ide0_mnk3lozhxu0w4f1g5wuusmwqedox2w1p~mv2.jpg"
* },
* {
* "_createdDate": "2023-07-16T08:56:10.000Z",
* "_id": "w8ide0_578uul37zvr7b6d7ji3cbm91rlf5dvjy.zip",
* "_updatedDate": "2023-07-20T07:16:55.000Z",
* "displayName": "pics",
* "hash": "tmk0uafvzzgkddrgwgl6od1h9jsp1j9e",
* "internalTags": [
* "_fileOrigin_uploaded"
* ],
* "labels": [],
* "media": {
* "archive": {
* "_id": "w8ide0_578uul37zvr7b6d7ji3cbm91rlf5dvjy.zip",
* "filename": "riverpics",
* "sizeInBytes": "49546083",
* "url": "https://3ecba886-4267-11ee-be56-0242ac120002.usrfiles.com/archives/w8ide0_578uul37zvr7b6d7ji3cbm91rlf5dvjy.zip"
* }
* },
* "mediaType": "ARCHIVE",
* "operationStatus": "READY",
* "parentFolderId": "media-root",
* "private": false,
* "siteId": "3ecba886-4267-11ee-be56-0242ac120002",
* "sizeInBytes": "49546083",
* "state": "OK",
* "thumbnailUrl": "https://static.wixstatic.com/media/48c4fbc47d7298cd4406936294b4c532.png",
* "url": "https://3ecba886-4267-11ee-be56-0242ac120002.usrfiles.com/archives/w8ide0_578uul37zvr7b6d7ji3cbm91rlf5dvjy.zip"
* },
* {
* "_createdDate": "2023-07-23T12:15:55.000Z",
* "_id": "w8ide0_87051wjiadg6qj2ywxb07vn5snqxxp2q",
* "_updatedDate": "2023-07-23T12:16:14.000Z",
* "displayName": "video1.mp4",
* "hash": "pdrepnjy3cdjq8bt2lzmpdvuc47mm921",
* "internalTags": [],
* "labels": [],
* "media": {
* "video": "wix:video://v1/w8ide0_87051wjiadg6qj2ywxb07vn5snqxxp2q/video1.mp4#posterUri=w8ide0_87051wjiadg6qj2ywxb07vn5snqxxp2qf001.jpg&posterWidth=1280&posterHeight=720"
* },
* "mediaType": "VIDEO",
* "operationStatus": "READY",
* "parentFolderId": "media-root",
* "private": false,
* "siteId": "3ecba886-4267-11ee-be56-0242ac120002",
* "sizeInBytes": "4384468",
* "sourceUrl": "https://cdn.pixabay.com/example.mp4",
* "state": "OK",
* "thumbnailUrl": "https://static.wixstatic.com/media/w8ide0_87051wjiadg6qj2ywxb07vn5snqxxp2qf002.jpg",
* "url": "https://video.wixstatic.com/video/w8ide0_87051wjiadg6qj2ywxb07vn5snqxxp2q/file"
* }
* ]
* }
*/
There is 1 error with this status code.
This method may also return standard errors. Learn more about standard Wix errors.
Imports a file to the Media Manager using an external URL.
The importFile()
function returns a Promise that resolves to the imported file's descriptor.
This function returns information about the imported file. Importing a file is the method through which you can add files to the Media Manager.
Use the parentFolderId
and filePath
parameters to specify which folder you want the file to be imported to.
If no folder is specified, the file is imported to the media-root
folder.
Note: When you import a file, it's not immediately available, meaning you can't manage or use the file straight away. Learn more about knowing when a file is ready.
To import a file, you need to do one of the following:
mimeType
field of the request. For example, mimeType: 'image/jpeg'
.displayName
or url
field of the request. For example, displayName: 'Example Image.jpeg
or url: https://www.example.com/image.jpeg
.Note: If you want to validate the media type, pass the file's expected media type in the optional mediaType
field of the request. For example, mediaType: 'IMAGE'
.
This function requires elevated permissions and runs only on the backend and on dashboard pages.
function importFile(
url: string,
options: ImportFileOptions,
): Promise<ImportFileResponse>;
Publicly accessible external file URL.
Options to use when importing a single file.
import { files } from "wix-media.v2";
/* Sample url value: 'https://example.org/filename.jpg' */
async function myImportFileFunction(url) {
try {
const importedFile = await files.importFile(url);
console.log("Imported file successfully:", importedFile);
return importedFile;
} catch (error) {
console.error(error);
// Handle the error
}
}
/* Promise resolves to:
* {
* "file": {
* "_createdDate": "2023-07-23T09:19:05.000Z",
* "_id": "w8ide0_leac4pwk8o11v8725j9ugcbe70x3alc0~mv2.jpg",
* "_updatedDate": "2023-07-23T09:19:05.000Z",
* "displayName": "image1.jpg",
* "hash": "",
* "internalTags": [],
* "labels": [],
* "mediaType": "IMAGE",
* "operationStatus": "PENDING",
* "parentFolderId": "media-root",
* "private": false,
* "sizeInBytes": "20167",
* "siteId": "3ecba886-4267-11ee-be56-0242ac120002",
* "sourceUrl": "https://example.org/filename.jpg",
* "state": "OK",
* "thumbnailUrl": "https://static.wixstatic.com/media/w8ide0_leac4pwk8o11v8725j9ugcbe70x3alc0~mv2.jpg",
* "url": "https://static.wixstatic.com/media/w8ide0_leac4pwk8o11v8725j9ugcbe70x3alc0~mv2.jpg"
* }
* }
*/
There is 1 error with this status code.
This method may also return standard errors. Learn more about standard Wix errors.
Retrieves a list of files in the Media Manager's trash bin.
The listDeletedFiles()
function returns a Promise that resolves to an array of the specified deleted files' descriptors and cursor information.
Note: The Media Manager's trash bin (TRASH_ROOT
folder) only contains temporarily deleted files, not permanently deleted files.
To retrieve a list of non-deleted files, use the listFiles()
function.
This function requires elevated permissions and runs only on the backend and on dashboard pages.
function listDeletedFiles(
options: ListDeletedFilesOptions,
): Promise<ListDeletedFilesResponse>;
Options to use when listing deleted files from the trash bin.
import { files } from "wix-media.v2";
async function myListDeletedFilesFunction() {
try {
const deletedFiles = await files.listDeletedFiles();
console.log("Files in trash:", deletedFiles);
return deletedFiles;
} catch (error) {
console.error(error);
// Handle the error
}
}
/* Promise resolves to:
* {
* "files": [
* {
* "_createdDate": "2023-08-09T08:45:42.000Z",
* "_id": "d4dde1_32288e20a5aa4213a52b15426fb27c9f~mv2.png",
* "_updatedDate": "2023-08-09T08:45:42.000Z",
* "displayName": "image1.png",
* "hash": "864d607a1ea270efbac32def181f039f",
* "internalTags": [
* "_fileOrigin_uploaded"
* ],
* "labels": [],
* "media": {
* "image": {
* "colors": {
* "palette": [
* {
* "rgb": {
* "b": 247,
* "g": 247,
* "r": 247
* }
* },
* {
* "rgb": {
* "b": 142,
* "g": 140,
* "r": 140
* }
* },
* {
* "rgb": {
* "b": 192,
* "g": 218,
* "r": 141
* }
* },
* {
* "rgb": {
* "b": 195,
* "g": 137,
* "r": 149
* }
* },
* {
* "rgb": {
* "b": 228,
* "g": 143,
* "r": 183
* }
* },
* {
* "rgb": {
* "b": 250,
* "g": 62,
* "r": 152
* }
* },
* {
* "rgb": {
* "b": 16,
* "g": 16,
* "r": 16
* }
* },
* {
* "rgb": {
* "b": 140,
* "g": 199,
* "r": 60
* }
* },
* {
* "rgb": {
* "b": 120,
* "g": 194,
* "r": 242
* }
* },
* {
* "rgb": {
* "b": 158,
* "g": 203,
* "r": 103
* }
* }
* ],
* "prominent": {
* "rgb": {
* "b": 247,
* "g": 247,
* "r": 247
* }
* }
* },
* "faces": [],
* "image": "wix:image://v1/d4dde1_32288e20a5aa4213a52b15426fb27c9f~mv2.png/image1.png#originWidth=1170&originHeight=2532"
* }
* },
* "mediaType": "IMAGE",
* "operationStatus": "READY",
* "parentFolderId": "trash-root",
* "private": false,
* "siteId": "3ecba886-4267-11ee-be56-0242ac120002",
* "sizeInBytes": "394945",
* "state": "OK",
* "thumbnailUrl": "https://static.wixstatic.com/media/d4dde1_32288e20a5aa4213a52b15426fb27c9f~mv2.png",
* "url": "https://static.wixstatic.com/media/d4dde1_32288e20a5aa4213a52b15426fb27c9f~mv2.png"
* },
* {
* "_createdDate": "2023-08-09T08:45:37.000Z",
* "_id": "d4dde1_8dd2bfe6121f43b29ebeaa63988abf54.svg",
* "_updatedDate": "2023-08-09T08:45:37.000Z",
* "displayName": "vectorArt1.svg",
* "hash": "e379083c3675d7f7891da00c0708539c",
* "internalTags": [
* "_fileOrigin_uploaded"
* ],
* "labels": [],
* "media": {
* "image": {
* "faces": [],
* "image": "wix:image://v1/d4dde1_8dd2bfe6121f43b29ebeaa63988abf54.svg/vectorArt1.svg#originWidth=1177&originHeight=2501"
* }
* },
* "mediaType": "VECTOR",
* "operationStatus": "READY",
* "parentFolderId": "trash-root",
* "private": false,
* "siteId": "3ecba886-4267-11ee-be56-0242ac120002",
* "sizeInBytes": "119475",
* "state": "OK",
* "thumbnailUrl": "https://static.wixstatic.com/shapes/d4dde1_8dd2bfe6121f43b29ebeaa63988abf54.svg",
* "url": "https://static.wixstatic.com/shapes/d4dde1_8dd2bfe6121f43b29ebeaa63988abf54.svg"
* }
* ],
* "nextCursor": {
* "cursors": {
* "next": ""
* },
* "hasNext": false
* }
* }
*/
There are 2 errors with this status code.
This method may also return standard errors. Learn more about standard Wix errors.
Retrieves a list of files in the Media Manager.
The listFiles()
function returns a Promise that resolves to an array of the specified files' descriptors and cursor information.
To retrieve a list of files within a specific folder in the Media Manager, pass the folder's ID in the parentFolderId
parameter. If no folder is specified, the function retrieves only the files in the root folder of the Media Manager.
To retrieve a list of (non-permanently) deleted files, use the listDeletedFiles()
function.
This function requires elevated permissions and runs only on the backend and on dashboard pages.
function listFiles(options: ListFilesOptions): Promise<ListFilesResponse>;
Options to use when listing media files.
import { files } from "wix-media.v2";
import { elevate } from "wix-auth";
/* Sample listOptions value:
* {
* parentFolderId : 'igje5u22nij3qkltzsnol37j3dnthvvh'
* }
*/
async function myListFilesFunction(listOptions) {
try {
const elevatedListFiles = elevate(files.listFiles);
const fileList = await elevatedListFiles(listOptions);
console.log("Files in folder:", fileList);
return fileList;
} catch (error) {
console.error(error);
// Handle the error
}
}
/* Promise resolves to:
* {
* "files": [
* {
* "_createdDate": "2023-07-16T08:56:07.000Z",
* "_id": "w8ide0_f4dRFF610cKd7zkjVbaNddXgb181lXfg.pdf",
* "_updatedDate": "2023-07-16T08:56:07.000Z",
* "displayName": "file1.pdf",
* "hash": "z3bxokp79p04ok6iiu9ao8srx5lrynfh",
* "internalTags": [
* "_fileOrigin_uploaded"
* ],
* "labels": [],
* "media": {
* "document": "wix:document://v1/w8ide0_f4dRFF610cKd7zkjVbaNddXgb181lXfg.pdf/file1.pdf"
* },
* "mediaType": "DOCUMENT",
* "operationStatus": "READY",
* "parentFolderId": "igje5u22nij3qkltzsnol37j3dnthvvh",
* "private": false,
* "siteId": "3ecba886-4267-11ee-be56-0242ac120002",
* "sizeInBytes": "187199",
* "state": "OK",
* "thumbnailUrl": "https://static.wixstatic.com/media/it7ucst133nc8d9e0ff4d0nay1ucksc6.png",
* "url": "https://3ecba886-4267-11ee-be56-0242ac120002.usrfiles.com/ugd/w8ide0_f4dRFF610cKd7zkjVbaNddXgb181lXfg.pdf"
* },
* {
* "_createdDate": "2023-07-16T08:56:07.000Z",
* "_id": "w8ide0_170y03n3akmstnpt5jmsju89wvgs9tg4.pdf",
* "_updatedDate": "2023-07-16T08:56:07.000Z",
* "displayName": "file2.pdf",
* "hash": "g6x41coggaystn596ndb09q1ecg036gk",
* "internalTags": [
* "_fileOrigin_uploaded"
* ],
* "labels": [],
* "media": {
* "document": "wix:document://v1/w8ide0_170y03n3akmstnpt5jmsju89wvgs9tg4.pdf/file2.pdf"
* },
* "mediaType": "DOCUMENT",
* "operationStatus": "READY",
* "parentFolderId": "igje5u22nij3qkltzsnol37j3dnthvvh",
* "private": false,
* "siteId": "3ecba886-4267-11ee-be56-0242ac120002",
* "sizeInBytes": "81624",
* "state": "OK",
* "thumbnailUrl": "https://static.wixstatic.com/media/it7ucst133nc8d9e0ff4d0nay1ucksc6.png",
* "url": "https://3ecba886-4267-11ee-be56-0242ac120002.usrfiles.com/ugd/w8ide0_170y03n3akmstnpt5jmsju89wvgs9tg4.pdf"
* }
* ],
* "nextCursor": {
* "cursors": {
* "next": ""
* },
* "hasNext": false
* }
* }
*/
There are 2 errors with this status code.
This method may also return standard errors. Learn more about standard Wix errors.
Searches all folders in the Media Manager and returns a list of files that match the terms specified in the optional parameters.
The searchFiles()
function returns a Promise that resolves to an array of the specified files' descriptors and cursor information.
If no parameters are specified, the function returns all files in the MEDIA_ROOT
folder.
This function requires elevated permissions and runs only on the backend and on dashboard pages.
function searchFiles(options: SearchFilesOptions): Promise<SearchFilesResponse>;
Options to specify which folders to search.
import { files } from "wix-media.v2";
async function mySearchFilesFunction() {
try {
const rootFiles = await files.searchFiles();
console.log("Files in MEDIA_ROOT", rootFiles);
return rootFiles;
} catch (error) {
console.error(error);
// Handle the error
}
}
/* Promise resolves to:
* {
* "files": [
* {
* "_createdDate": "2023-07-16T08:54:05.000Z",
* "_id": "w8ide0_ouulk5w0mdr9omjkwsfyn71g4mb1olcf~mv2.jpg",
* "_updatedDate": "2023-07-16T08:54:05.000Z",
* "displayName": "image2.jpg",
* "hash": "800fae3e0cb7908518a391c25864436c",
* "internalTags": [
* "_fileOrigin_uploaded"
* ],
* "labels": [
* "label1",
* "label2",
* "label3",
* "label4"
* ],
* "media": {
* "image": {
* "colors": {
* "palette": [
* {
* "rgb": {
* "b": 47,
* "g": 36,
* "r": 31
* }
* },
* {
* "rgb": {
* "b": 155,
* "g": 153,
* "r": 195
* }
* },
* {
* "rgb": {
* "b": 141,
* "g": 123,
* "r": 138
* }
* },
* {
* "rgb": {
* "b": 177,
* "g": 161,
* "r": 190
* }
* },
* {
* "rgb": {
* "b": 179,
* "g": 178,
* "r": 217
* }
* },
* {
* "rgb": {
* "b": 160,
* "g": 176,
* "r": 229
* }
* },
* {
* "rgb": {
* "b": 176,
* "g": 151,
* "r": 162
* }
* },
* {
* "rgb": {
* "b": 93,
* "g": 78,
* "r": 71
* }
* },
* {
* "rgb": {
* "b": 45,
* "g": 63,
* "r": 107
* }
* },
* {
* "rgb": {
* "b": 104,
* "g": 88,
* "r": 82
* }
* }
* ],
* "prominent": {
* "rgb": {
* "b": 26,
* "g": 36,
* "r": 39
* }
* }
* },
* "faces": [],
* "image": "wix:image://v1/w8ide0_ouulk5w0mdr9omjkwsfyn71g4mb1olcf~mv2.jpg/image2.jpg#originWidth=5833&originHeight=3894"
* }
* },
* "mediaType": "IMAGE",
* "operationStatus": "READY",
* "parentFolderId": "media-root",
* "private": false,
* "siteId": "3ecba886-4267-11ee-be56-0242ac120002",
* "sizeInBytes": "3013886",
* "state": "OK",
* "thumbnailUrl": "https://static.wixstatic.com/media/w8ide0_ouulk5w0mdr9omjkwsfyn71g4mb1olcf~mv2.jpg",
* "url": "https://static.wixstatic.com/media/w8ide0_ouulk5w0mdr9omjkwsfyn71g4mb1olcf~mv2.jpg"
* },
* {
* "_createdDate": "2023-07-16T08:56:07.000Z",
* "_id": "w8ide0_suuti24j47vesffndm8hkd651u72vp3f~mv2.jpg",
* "_updatedDate": "2023-07-16T08:56:07.000Z",
* "displayName": "image1.jpg",
* "hash": "fef0ylitxcnlyzxf0nahu8rh3k0i5t85",
* "internalTags": [
* "_fileOrigin_uploaded"
* ],
* "labels": [
* "label1"
* ],
* "media": {
* "image": {
* "colors": {
* "palette": [
* {
* "rgb": {
* "b": 26,
* "g": 36,
* "r": 39
* }
* },
* {
* "rgb": {
* "b": 135,
* "g": 125,
* "r": 119
* }
* },
* {
* "rgb": {
* "b": 208,
* "g": 209,
* "r": 208
* }
* },
* {
* "rgb": {
* "b": 40,
* "g": 108,
* "r": 130
* }
* },
* {
* "rgb": {
* "b": 133,
* "g": 101,
* "r": 75
* }
* },
* {
* "rgb": {
* "b": 36,
* "g": 78,
* "r": 94
* }
* },
* {
* "rgb": {
* "b": 178,
* "g": 161,
* "r": 148
* }
* },
* {
* "rgb": {
* "b": 192,
* "g": 177,
* "r": 163
* }
* },
* {
* "rgb": {
* "b": 159,
* "g": 184,
* "r": 208
* }
* },
* {
* "rgb": {
* "b": 137,
* "g": 159,
* "r": 183
* }
* }
* ],
* "prominent": {
* "rgb": {
* "b": 26,
* "g": 36,
* "r": 39
* }
* }
* },
* "faces": [],
* "image": "wix:image://v1/w8ide0_suuti24j47vesffndm8hkd651u72vp3f~mv2.jpg/image1.jpg#originWidth=5616&originHeight=3744"
* }
* },
* "mediaType": "IMAGE",
* "operationStatus": "READY",
* "parentFolderId": "media-root",
* "private": false,
* "siteId": "3ecba886-4267-11ee-be56-0242ac120002",
* "sizeInBytes": "6312959",
* "state": "OK",
* "thumbnailUrl": "https://static.wixstatic.com/media/w8ide0_suuti24j47vesffndm8hkd651u72vp3f~mv2.jpg",
* "url": "https://static.wixstatic.com/media/w8ide0_suuti24j47vesffndm8hkd651u72vp3f~mv2.jpg"
* },
* {
* "_createdDate": "2023-07-16T08:56:10.000Z",
* "_id": "w8ide0_9yvsg5vv40flojo0120h0rz6ki4g0tur.zip",
* "_updatedDate": "2023-07-16T08:56:10.000Z",
* "displayName": "file1.zip",
* "hash": "urm9iak1w39pk381ucb9kqjphya8loro",
* "internalTags": [
* "_fileOrigin_uploaded"
* ],
* "labels": [],
* "media": {
* "archive": {
* "_id": "w8ide0_9yvsg5vv40flojo0120h0rz6ki4g0tur.zip",
* "filename": "file1.zip",
* "sizeInBytes": "49546083",
* "url": "https://3ecba886-4267-11ee-be56-0242ac120002.usrfiles.com/archives/w8ide0_9yvsg5vv40flojo0120h0rz6ki4g0tur.zip"
* }
* },
* "mediaType": "ARCHIVE",
* "operationStatus": "READY",
* "parentFolderId": "media-root",
* "private": false,
* "siteId": "3ecba886-4267-11ee-be56-0242ac120002",
* "sizeInBytes": "49546083",
* "state": "OK",
* "thumbnailUrl": "https://static.wixstatic.com/media/48c4fbc47d7298cd4406936294b4c532.png",
* "url": "https://3ecba886-4267-11ee-be56-0242ac120002.usrfiles.com/archives/w8ide0_9yvsg5vv40flojo0120h0rz6ki4g0tur.zip"
* }
* ],
* "nextCursor": {
* "cursors": {
* "next": ""
* },
* "hasNext": false
* }
* }
*/
There are 2 errors with this status code.
This method may also return standard errors. Learn more about standard Wix errors.
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.