> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # Method name: listFiles(filters: FileFilterOptions, sorting: SortingOptions, paging: PagingOptions) # Method package: wixMediaBackend # Method menu location: wixMediaBackend --> MediaManager --> listFiles # Method Link: https://dev.wix.com/docs/velo/apis/wix-media-backend/media-manager/list-files.md # Method Description: Gets a list of files from the Media Manager by `parentFolderId` (or root). The `listFiles()` function returns a Promise that resolves to information about the files in the folder. To get 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 `listFiles()` function returns the list of files in the root folder of the Media Manager. >**Notes:** > * This function's parameters are positional, and must be specified in the sequence shown in the syntax below. When specifying a parameter, use `null` as a placeholder for any unspecified parameters. For example, to specify `parentFolderId` only, call `listFiles(filters, null, null)`. For example, to specify `sorting` only, call `listFiles(null, sorting, null)`. > > * The `listFiles()` function only gets a list of files with supported media types, and that are explicitly listed in the Media Manager. Files with unsupported media types such as 'model', and files that aren't explicitly listed in the Media Manager such as default files in a gallery component, aren't listed when calling the `listFiles()` function. The supported media types are listed in the description for the `mediaType` return in the [`getFileInfo()`](https://dev.wix.com/docs/velo/api-reference/wix-media-backend/media-manager/get-file-info.md) function. # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## List files in a specified folder ```javascript import { Permissions, webMethod } from 'wix-web-module'; import { mediaManager } from 'wix-media-backend'; const filters = { parentFolderId: "8a3be85ea03e4b8b82f2f9c989557c3d" }; export const myListFilesFunction = webMethod(Permissions.Anyone, () => { return mediaManager.listFiles(filters, null, null) .then((myFiles) => { const originalFileName = myFiles[0].originalFileName; const fileUrl = myFiles[1].fileUrl; return myFiles; }) .catch((error) => { console.error(error); }); }); /* Returns a promise that resolves to: * [{ * "fileUrl": "wix:image://v1/f6c0f9_tg439f4475a749e181dd14407fdbd37e~mv2.jpg/original-name.jpg#originWidth=300&originHeight=300", * "hash": "Ew00kXbu4Zt33rzjcWa6Ng==", * "sizeInBytes": 51085, * "mimeType": "image/jpeg", * "mediaType": "image", * "isPrivate": false, * "iconUrl": "wix:image://v1/f6c0f9_tg439f4475a749e181dd14407fdbd37e~mv2.jpg/original-name.jpg#originWidth=300&originHeight=300", * "parentFolderId": "8a3be85ea03e4b8b82f2f9c989557c3d", * "originalFileName": "original-name1.jpg", * "width": 300, * "height": 300, * "labels": [ * "Blue", * "Butterfly", * "Turquoise" * ], * "_createdDate": "Sun December 4 2020 10:56:09 GMT+0300", * "_updatedDate": "Wed May 12 2021 14:27:15 GMT+0300" * }, * { * "fileUrl": "wix:image://v1/8b7eef_47332c4ae5b74db89d86d5d9e0cd303b~mv2.png/Screen%20Shot%202021-05-19%20at%209.59.29.png#originWidth=984&originHeight=1230", * "hash": "93fea6d1c6f7b10e24a729b0402ac152", * "sizeInBytes": 232794, * "mimeType": "image/jpeg", * "mediaType": "image", * "isPrivate": false, * "iconUrl": "wix:image://v1/8b7eef_47332c4ae5b74db89d86d5d9e0cd303b~mv2.png/Screen%20Shot%202021-05-19%20at%209.59.29.png#originWidth=984&originHeight=1230", * "parentFolderId": "8a3be85ea03e4b8b82f2f9c989557c3d", * "originalFileName": "original-name2.jpg", * "sourceUrl": "https://somedomain.com/img/original-name.jpg", * "width": 984, * "height": 221, * "labels": [ * "Font", * "Type", * "Write" * ], * "opStatus": "READY", * "_createdDate": "Tues January 22 2020 12:56:02 GMT+0300", * "_updatedDate": "Fri October 9 2020 04:56:22 GMT+0300" * }] */ ``` ## List files in the root folder ```javascript import { Permissions, webMethod } from 'wix-web-module'; import { mediaManager } from 'wix-media-backend'; export const myListFilesFunction = webMethod(Permissions.Anyone, () => { return mediaManager.listFiles() .then((myFiles) => { const originalFileName = myFiles[0].originalFileName; const fileUrl = myFiles[0].fileUrl; return myFiles; }) .catch((error) => { console.error(error); }); }); /* Returns a promise that resolves to: * [{ * "fileUrl": "wix:image://v1/g9c0f9_tg422f4475a749e661dd14407fdbd37k~mv2.jpg/original-name.jpg#originWidth=300&originHeight=300", * "hash": "Pq00kXbvu4Zt3239rzjcWa6Ng==", * "sizeInBytes": 23746, * "mimeType": "image/jpeg", * "mediaType": "image", * "isPrivate": false, * "iconUrl": "wix:image://v1/g9c0f9_tg422f4475a749e661dd14407fdbd37k~mv2.jpg/original-name.jpg#originWidth=300&originHeight=300", * "parentFolderId": "media-root", * "originalFileName": "original-name.jpg", * "width": 220, * "height": 340, * "labels": [ * "Sand", * "Beach" * ], * "_createdDate": "Mon September 2 2019 13:56:06 GMT+0300", * "_updatedDate": "Sat June 20 2020 14:33:07 GMT+0300" * }] */ ``` ## Filter, sort, and paginate a list of files ```javascript import { Permissions, webMethod } from 'wix-web-module'; import { mediaManager } from 'wix-media-backend'; const filters = { parentFolderId: "9162670cf5434db787bdd9715b46b473", mediaType: "image", isPrivate: false }; const sorting = { order: "asc", field: "originalFileName" }; const paging = { limit: 3, skip: 1 }; export const myListFilesFunction = webMethod(Permissions.Anyone, () => { return mediaManager.listFiles(filters, sorting, paging) .then((myFiles) => { const originalFileName = myFiles[0].originalFileName; const fileUrl = myFiles[1].fileUrl; return myFiles; }) .catch((error) => { console.error(error); }); }); /* Returns a promise that resolves to: * [{ * "fileUrl": "wix:image://v1/p0c0f9_tg439f4475a749e181dd14407fdbd99e~mv2.~mv2.jpg/original-name.jpg#originWidth=300&originHeight=300", * "hash": "Ew00kXbu4Zt33rzjcWa6Ng==", * "sizeInBytes": 51085, * "mimeType": "image/jpeg", * "mediaType": "image", * "isPrivate": false, * "iconUrl": "wix:image://v1/p0c0f9_tg439f4475a749e181dd14407fdbd99e~mv2.~mv2.jpg/original-name.jpg#originWidth=300&originHeight=300", * "parentFolderId": "9162670cf5434db787bdd9715b46b473", * "originalFileName": "apple.jpg", * "width": 300, * "height": 300, * "labels": [ * "Green", * "Tree", * "Worm" * ], * "_createdDate": "Mon October 5 2018 14:26:27 GMT+0300", * "_updatedDate": "Wed May 12 2021 11:12:45 GMT+0300" * }, * { * "fileUrl": "wix:image://v1/qr7eef_47332c4ae5b74db89d86d5d9e0cd303b~mv2.png/Screen%20Shot%202021-05-19%20at%209.59.29.png#originWidth=984&originHeight=1230", * "hash": "93fea6d1c6f7b10e24a729b0402ac152", * "sizeInBytes": 232794, * "mimeType": "image/jpeg", * "mediaType": "image", * "isPrivate": false, * "iconUrl": "wix:image://v1/qr7eef_47332c4ae5b74db89d86d5d9e0cd303b~mv2.png/Screen%20Shot%202021-05-19%20at%209.59.29.png#originWidth=984&originHeight=1230", * "parentFolderId": "9162670cf5434db787bdd9715b46b473", * "originalFileName": "banana.jpg", * "sourceUrl": "https://somedomain.com/img/original-name.jpg", * "width": 984, * "height": 221, * "labels": [ * "Yellow", * "Peel" * ], * "opStatus": "READY", * "_createdDate": "Sun February 04 2016 02:29:07 GMT+0300", * "_updatedDate": "Fri October 9 2020 09:33:22 GMT+0300" * }, * { * "fileUrl": "wix:image://v1/nm8ttl_47332c4ae5b74db89d86d5d9e0cd303b~mv2.png/Screen%20Shot%202021-05-19%20at%209.59.29.png#originWidth=984&originHeight=1230", * "hash": "93fea6d1c6f7b10e24a729b0402ac152", * "sizeInBytes": 122794, * "mimeType": "image/jpeg", * "mediaType": "image", * "isPrivate": false, * "iconUrl": "wix:image://v1/nm8ttl_47332c4ae5b74db89d86d5d9e0cd303b~mv2.png/Screen%20Shot%202021-05-19%20at%209.59.29.png#originWidth=984&originHeight=1230", * "parentFolderId": "9162670cf5434db787bdd9715b46b473", * "originalFileName": "cherry.jpg", * "width": 200, * "height": 400, * "labels": [ * "Red", * "Stem" * ], * "_createdDate": "Tues January 22 2019 12:56:02 GMT+0300", * "_updatedDate": "Thurs March 11 2021 05:44:20 GMT+0300" * }] */ ``` ---