listFiles( )
Gets a list of files from the Media Manager by parentFolderId
(or root).
Description
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 specifyparentFolderId
only, calllistFiles(filters, null, null)
. For example, to specifysorting
only, calllistFiles(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 thelistFiles()
function. The supported media types are listed in the description for themediaType
return in thegetFileInfo()
function.
Authorization
Request
This endpoint does not take any parameters
Response Object
Fulfilled - Information about the files.
NAME
TYPE
DESCRIPTION
Deprecated. Use the fileUrl
property instead.
The fileName
property is the internal name (unique identifier) which is generated when a file is uploaded by the Media Manager, returned from the importFile()
, or upload()
functions. The name is the string located in the file's URL. Click here to learn more. Use this name when calling the getFileInfo()
, getFileUrl()
,
and getVideoPlaybackUrl()
functions.
The file's Wix media URL in the following format: 'wix:image://v1/<uri>/<filename>#originWidth=<width>&originHeight=<height>[&watermark=<watermark_manifest_string>]'
.
File hash.
Size of the listed file in bytes.
Media type of the listed file. One of:
"audio"
"document"
"image"
"shape"
"video"
Whether the link to the listed file is public or private. Private links require a token to be used.
ID of the file's parent folder.
Original name of the uploaded file. This is the display name that appears in the Media Manager.
URL of the file's icon.
List of labels assigned to the file by the Media Manager.
Media height.
Media width.
Date the file was created.
Date the file was updated.
Status/Error Codes
Was this helpful?
1import { mediaManager } from 'wix-media-backend';23const filters = {4 parentFolderId: "8a3be85ea03e4b8b82f2f9c989557c3d"5};67export function myListFilesFunction() {8 return mediaManager.listFiles(filters, null, null)9 .then((myFiles) => {10 const originalFileName = myFiles[0].originalFileName;11 const fileUrl = myFiles[1].fileUrl;12 return myFiles;13 })14 .catch((error) => {15 console.error(error);16 });17}1819/* Returns a promise that resolves to:20 * [{21 * "fileUrl": "wix:image://v1/f6c0f9_tg439f4475a749e181dd14407fdbd37e~mv2.jpg/original-name.jpg#originWidth=300&originHeight=300",22 * "hash": "Ew00kXbu4Zt33rzjcWa6Ng==",23 * "sizeInBytes": 51085,24 * "mimeType": "image/jpeg",25 * "mediaType": "image",26 * "isPrivate": false,27 * "iconUrl": "wix:image://v1/f6c0f9_tg439f4475a749e181dd14407fdbd37e~mv2.jpg/original-name.jpg#originWidth=300&originHeight=300",28 * "parentFolderId": "8a3be85ea03e4b8b82f2f9c989557c3d",29 * "originalFileName": "original-name1.jpg",30 * "width": 300,31 * "height": 300,32 * "labels": [33 * "Blue",34 * "Butterfly",35 * "Turquoise"36 * ],37 * "_createdDate": "Sun December 4 2020 10:56:09 GMT+0300",38 * "_updatedDate": "Wed May 12 2021 14:27:15 GMT+0300"39 * },40 * {41 * "fileUrl": "wix:image://v1/8b7eef_47332c4ae5b74db89d86d5d9e0cd303b~mv2.png/Screen%20Shot%202021-05-19%20at%209.59.29.png#originWidth=984&originHeight=1230",42 * "hash": "93fea6d1c6f7b10e24a729b0402ac152",43 * "sizeInBytes": 232794,44 * "mimeType": "image/jpeg",45 * "mediaType": "image",46 * "isPrivate": false,47 * "iconUrl": "wix:image://v1/8b7eef_47332c4ae5b74db89d86d5d9e0cd303b~mv2.png/Screen%20Shot%202021-05-19%20at%209.59.29.png#originWidth=984&originHeight=1230",48 * "parentFolderId": "8a3be85ea03e4b8b82f2f9c989557c3d",49 * "originalFileName": "original-name2.jpg",50 * "sourceUrl": "https://somedomain.com/img/original-name.jpg",51 * "width": 984,52 * "height": 221,53 * "labels": [54 * "Font",55 * "Type",56 * "Write"57 * ],58 * "opStatus": "READY",59 * "_createdDate": "Tues January 22 2020 12:56:02 GMT+0300",60 * "_updatedDate": "Fri October 9 2020 04:56:22 GMT+0300"61 * }]62 */
1import { mediaManager } from 'wix-media-backend';23export function myListFilesFunction() {4 return mediaManager.listFiles()5 .then((myFiles) => {6 const originalFileName = myFiles[0].originalFileName;7 const fileUrl = myFiles[0].fileUrl;8 return myFiles;9 })10 .catch((error) => {11 console.error(error);12 });13}141516/* Returns a promise that resolves to:17 * [{18 * "fileUrl": "wix:image://v1/g9c0f9_tg422f4475a749e661dd14407fdbd37k~mv2.jpg/original-name.jpg#originWidth=300&originHeight=300",19 * "hash": "Pq00kXbvu4Zt3239rzjcWa6Ng==",20 * "sizeInBytes": 23746,21 * "mimeType": "image/jpeg",22 * "mediaType": "image",23 * "isPrivate": false,24 * "iconUrl": "wix:image://v1/g9c0f9_tg422f4475a749e661dd14407fdbd37k~mv2.jpg/original-name.jpg#originWidth=300&originHeight=300",25 * "parentFolderId": "media-root",26 * "originalFileName": "original-name.jpg",27 * "width": 220,28 * "height": 340,29 * "labels": [30 * "Sand",31 * "Beach"32 * ],33 * "_createdDate": "Mon September 2 2019 13:56:06 GMT+0300",34 * "_updatedDate": "Sat June 20 2020 14:33:07 GMT+0300"35 * }]36 */
In this example we list image files in a specified folder that are public, and sort them in ascending alphabetical order according to the original file name. We skip the first file in the list and limit the result to the next 3 files in the list.
1import { mediaManager } from 'wix-media-backend';23const filters = {4 parentFolderId: "9162670cf5434db787bdd9715b46b473",5 mediaType: "image",6 isPrivate: false7};89const sorting = {10 order: "asc",11 field: "originalFileName"12};1314const paging = {15 limit: 3,16 skip: 117};1819export function myListFilesFunction() {20 return mediaManager.listFiles(filters, sorting, paging)21 .then((myFiles) => {22 const originalFileName = myFiles[0].originalFileName;23 const fileUrl = myFiles[1].fileUrl;24 return myFiles;25 })26 .catch((error) => {27 console.error(error);28 });29}303132/* Returns a promise that resolves to:33 * [{34 * "fileUrl": "wix:image://v1/p0c0f9_tg439f4475a749e181dd14407fdbd99e~mv2.~mv2.jpg/original-name.jpg#originWidth=300&originHeight=300",35 * "hash": "Ew00kXbu4Zt33rzjcWa6Ng==",36 * "sizeInBytes": 51085,37 * "mimeType": "image/jpeg",38 * "mediaType": "image",39 * "isPrivate": false,40 * "iconUrl": "wix:image://v1/p0c0f9_tg439f4475a749e181dd14407fdbd99e~mv2.~mv2.jpg/original-name.jpg#originWidth=300&originHeight=300",41 * "parentFolderId": "9162670cf5434db787bdd9715b46b473",42 * "originalFileName": "apple.jpg",43 * "width": 300,44 * "height": 300,45 * "labels": [46 * "Green",47 * "Tree",48 * "Worm"49 * ],50 * "_createdDate": "Mon October 5 2018 14:26:27 GMT+0300",51 * "_updatedDate": "Wed May 12 2021 11:12:45 GMT+0300"52 * },53 * {54 * "fileUrl": "wix:image://v1/qr7eef_47332c4ae5b74db89d86d5d9e0cd303b~mv2.png/Screen%20Shot%202021-05-19%20at%209.59.29.png#originWidth=984&originHeight=1230",55 * "hash": "93fea6d1c6f7b10e24a729b0402ac152",56 * "sizeInBytes": 232794,57 * "mimeType": "image/jpeg",58 * "mediaType": "image",59 * "isPrivate": false,60 * "iconUrl": "wix:image://v1/qr7eef_47332c4ae5b74db89d86d5d9e0cd303b~mv2.png/Screen%20Shot%202021-05-19%20at%209.59.29.png#originWidth=984&originHeight=1230",61 * "parentFolderId": "9162670cf5434db787bdd9715b46b473",62 * "originalFileName": "banana.jpg",63 * "sourceUrl": "https://somedomain.com/img/original-name.jpg",64 * "width": 984,65 * "height": 221,66 * "labels": [67 * "Yellow",68 * "Peel"69 * ],70 * "opStatus": "READY",71 * "_createdDate": "Sun February 04 2016 02:29:07 GMT+0300",72 * "_updatedDate": "Fri October 9 2020 09:33:22 GMT+0300"73 * },74 * {75 * "fileUrl": "wix:image://v1/nm8ttl_47332c4ae5b74db89d86d5d9e0cd303b~mv2.png/Screen%20Shot%202021-05-19%20at%209.59.29.png#originWidth=984&originHeight=1230",76 * "hash": "93fea6d1c6f7b10e24a729b0402ac152",77 * "sizeInBytes": 122794,78 * "mimeType": "image/jpeg",79 * "mediaType": "image",80 * "isPrivate": false,81 * "iconUrl": "wix:image://v1/nm8ttl_47332c4ae5b74db89d86d5d9e0cd303b~mv2.png/Screen%20Shot%202021-05-19%20at%209.59.29.png#originWidth=984&originHeight=1230",82 * "parentFolderId": "9162670cf5434db787bdd9715b46b473",83 * "originalFileName": "cherry.jpg",84 * "width": 200,85 * "height": 400,86 * "labels": [87 * "Red",88 * "Stem"89 * ],90 * "_createdDate": "Tues January 22 2019 12:56:02 GMT+0300",91 * "_updatedDate": "Thurs March 11 2021 05:44:20 GMT+0300"92 * }]93 */949596