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.