Search.../

listFiles( )

Gets a list of files from the Media Manager by folder Id (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.

Syntax

function listFiles(filters: FileFilterOptions, sort: SortingOptions, pagination: PaginationOptions): File

listFiles Parameters

NAME
TYPE
DESCRIPTION
filters
FileFilterOptions

File filter options.

sort
SortingOptions

Sorting options.

pagination
PaginationOptions

Pagination options.

Returns

Fulfilled - Information about the files.

Return Type:

Promise<Array<File>>
NAME
TYPE
DESCRIPTION
fileName
string

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.

fileUrl
string

URL of the file.

hash
string

File hash.

sizeInBytes
number

Size of the listed file in bytes.

mimeType
string

Mime type of the listed file.

mediaType
string

Media type of the listed file. One of:

  • "audio"
  • "document"
  • "image"
  • "shape"
  • "video"
isPrivate
boolean

Whether the link to the listed file is public or private. Private links require a token to be used.

parentFolderId
string

ID of the file's parent folder.

originalFileName
string

Original name of the uploaded file. This is the display name that appears in the Media Manager.

iconUrl
string

URL of the file's icon.

labels
Array<string>

List of labels assigned to the file by the Media Manager.

height
string

File height.

width
string

File width.

_createdDate
Date

Date the file was created.

_updatedDate
Date

Date the file was updated.

Was this helpful?

List files in a specified folder

Copy Code
1import { mediaManager } from 'wix-media-backend';
2
3const filters = {
4 parentFolderId: "8a3be85ea03e4b8b82f2f9c989557c3d"
5};
6
7export function myListFilesFunction() {
8 return mediaManager.listFiles(filters)
9 .then((myFiles) => {
10 const originalFileName = myFiles[0].originalFileName;
11 const fileName = myFiles[1].fileName;
12 return myFiles;
13 })
14 .catch((error) => {
15 console.error(error);
16 });
17}
18
19/* Returns a promise that resolves to:
20 * [{
21 * "fileName": "f6c0f9_tg439f4475a749e181dd14407fdbd37e~mv2.jpg",
22 * "fileUrl": "wix:image://v1/f6c0f9_tg439f4475a749e181dd14407fdbd37e~mv2.jpg/original-name.jpg#originWidth=300&originHeight=300",
23 * "hash": "Ew00kXbu4Zt33rzjcWa6Ng==",
24 * "sizeInBytes": 51085,
25 * "mimeType": "image/jpeg",
26 * "mediaType": "image",
27 * "isPrivate": false,
28 * "iconUrl": "wix:image://v1/f6c0f9_tg439f4475a749e181dd14407fdbd37e~mv2.jpg/original-name.jpg#originWidth=300&originHeight=300",
29 * "parentFolderId": "8a3be85ea03e4b8b82f2f9c989557c3d",
30 * "originalFileName": "original-name1.jpg",
31 * "width": 300,
32 * "height": 300,
33 * "labels": [
34 * "Blue",
35 * "Butterfly",
36 * "Turquoise"
37 * ],
38 * "_createdDate": "Sun December 4 2020 10:56:09 GMT+0300",
39 * "_updatedDate": "Wed May 12 2021 14:27:15 GMT+0300"
40 * },
41 * {
42 * "fileName": "8b7eef_47332c4ae5b74db89d86d5d9e0cd303b~mv2.png",
43 * "fileUrl": "wix:image://v1/8b7eef_47332c4ae5b74db89d86d5d9e0cd303b~mv2.png/Screen%20Shot%202021-05-19%20at%209.59.29.png#originWidth=984&originHeight=1230",
44 * "hash": "93fea6d1c6f7b10e24a729b0402ac152",
45 * "sizeInBytes": 232794,
46 * "mimeType": "image/jpeg",
47 * "mediaType": "image",
48 * "isPrivate": false,
49 * "iconUrl": "wix:image://v1/8b7eef_47332c4ae5b74db89d86d5d9e0cd303b~mv2.png/Screen%20Shot%202021-05-19%20at%209.59.29.png#originWidth=984&originHeight=1230",
50 * "parentFolderId": "8a3be85ea03e4b8b82f2f9c989557c3d",
51 * "originalFileName": "original-name2.jpg",
52 * "sourceUrl": "https://somedomain.com/img/original-name.jpg",
53 * "width": 984,
54 * "height": 221,
55 * "labels": [
56 * "Font",
57 * "Type",
58 * "Write"
59 * ],
60 * "opStatus": "READY",
61 * "_createdDate": "Tues January 22 2020 12:56:02 GMT+0300",
62 * "_updatedDate": "Fri October 9 2020 04:56:22 GMT+0300"
63 * }]
64 */
List files in the root folder

Copy Code
1import { mediaManager } from 'wix-media-backend';
2
3export function myListFilesFunction() {
4 return mediaManager.listFiles()
5 .then((myFiles) => {
6 const originalFileName = myFiles[0].originalFileName;
7 const fileName = myFiles[0].fileName;
8 return myFiles;
9 })
10 .catch((error) => {
11 console.error(error);
12 });
13}
14
15
16/* Returns a promise that resolves to:
17 * [{
18 * "fileName": "g9c0f9_tg422f4475a749e661dd14407fdbd37k~mv2.jpg",
19 * "fileUrl": "wix:image://v1/g9c0f9_tg422f4475a749e661dd14407fdbd37k~mv2.jpg/original-name.jpg#originWidth=300&originHeight=300",
20 * "hash": "Pq00kXbvu4Zt3239rzjcWa6Ng==",
21 * "sizeInBytes": 23746,
22 * "mimeType": "image/jpeg",
23 * "mediaType": "image",
24 * "isPrivate": false,
25 * "iconUrl": "wix:image://v1/g9c0f9_tg422f4475a749e661dd14407fdbd37k~mv2.jpg/original-name.jpg#originWidth=300&originHeight=300",
26 * "parentFolderId": "media-root",
27 * "originalFileName": "original-name.jpg",
28 * "width": 220,
29 * "height": 340,
30 * "labels": [
31 * "Sand",
32 * "Beach"
33 * ],
34 * "_createdDate": "Mon September 2 2019 13:56:06 GMT+0300",
35 * "_updatedDate": "Sat June 20 2020 14:33:07 GMT+0300"
36 * }]
37 */
Filter, sort, and paginate a list of files

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.

Copy Code
1import { mediaManager } from 'wix-media-backend';
2
3const filters = {
4 parentFolderId: "9162670cf5434db787bdd9715b46b473",
5 mediaType: "image",
6 isPrivate: false
7};
8
9const sort = {
10 order: "asc",
11 field: "originalFileName"
12};
13
14const pagination = {
15 limit: 3,
16 skip: 1
17};
18
19export function myListFilesFunction() {
20 return mediaManager.listFiles(filters, sort, pagination)
21 .then((myFiles) => {
22 const originalFileName = myFiles[0].originalFileName;
23 const fileName = myFiles[1].fileName;
24 return myFiles;
25 })
26 .catch((error) => {
27 console.error(error);
28 });
29}
30
31
32/* Returns a promise that resolves to:
33 * [{
34 * "fileName": "p0c0f9_tg439f4475a749e181dd14407fdbd99e~mv2.jpg",
35 * "fileUrl": "wix:image://v1/p0c0f9_tg439f4475a749e181dd14407fdbd99e~mv2.~mv2.jpg/original-name.jpg#originWidth=300&originHeight=300",
36 * "hash": "Ew00kXbu4Zt33rzjcWa6Ng==",
37 * "sizeInBytes": 51085,
38 * "mimeType": "image/jpeg",
39 * "mediaType": "image",
40 * "isPrivate": false,
41 * "iconUrl": "wix:image://v1/p0c0f9_tg439f4475a749e181dd14407fdbd99e~mv2.~mv2.jpg/original-name.jpg#originWidth=300&originHeight=300",
42 * "parentFolderId": "9162670cf5434db787bdd9715b46b473",
43 * "originalFileName": "apple.jpg",
44 * "width": 300,
45 * "height": 300,
46 * "labels": [
47 * "Green",
48 * "Tree",
49 * "Worm"
50 * ],
51 * "_createdDate": "Mon October 5 2018 14:26:27 GMT+0300",
52 * "_updatedDate": "Wed May 12 2021 11:12:45 GMT+0300"
53 * },
54 * {
55 * "fileName": "qr7eef_47332c4ae5b74db89d86d5d9e0cd303b~mv2.png",
56 * "fileUrl": "wix:image://v1/qr7eef_47332c4ae5b74db89d86d5d9e0cd303b~mv2.png/Screen%20Shot%202021-05-19%20at%209.59.29.png#originWidth=984&originHeight=1230",
57 * "hash": "93fea6d1c6f7b10e24a729b0402ac152",
58 * "sizeInBytes": 232794,
59 * "mimeType": "image/jpeg",
60 * "mediaType": "image",
61 * "isPrivate": false,
62 * "iconUrl": "wix:image://v1/qr7eef_47332c4ae5b74db89d86d5d9e0cd303b~mv2.png/Screen%20Shot%202021-05-19%20at%209.59.29.png#originWidth=984&originHeight=1230",
63 * "parentFolderId": "9162670cf5434db787bdd9715b46b473",
64 * "originalFileName": "banana.jpg",
65 * "sourceUrl": "https://somedomain.com/img/original-name.jpg",
66 * "width": 984,
67 * "height": 221,
68 * "labels": [
69 * "Yellow",
70 * "Peel"
71 * ],
72 * "opStatus": "READY",
73 * "_createdDate": "Sun February 04 2016 02:29:07 GMT+0300",
74 * "_updatedDate": "Fri October 9 2020 09:33:22 GMT+0300"
75 * },
76 * {
77 * "fileName": "nm8ttl_47332c4ae5b74db89d86d5d9e0cd303b~mv2.png",
78 * "fileUrl": "wix:image://v1/nm8ttl_47332c4ae5b74db89d86d5d9e0cd303b~mv2.png/Screen%20Shot%202021-05-19%20at%209.59.29.png#originWidth=984&originHeight=1230",
79 * "hash": "93fea6d1c6f7b10e24a729b0402ac152",
80 * "sizeInBytes": 122794,
81 * "mimeType": "image/jpeg",
82 * "mediaType": "image",
83 * "isPrivate": false,
84 * "iconUrl": "wix:image://v1/nm8ttl_47332c4ae5b74db89d86d5d9e0cd303b~mv2.png/Screen%20Shot%202021-05-19%20at%209.59.29.png#originWidth=984&originHeight=1230",
85 * "parentFolderId": "9162670cf5434db787bdd9715b46b473",
86 * "originalFileName": "cherry.jpg",
87 * "width": 200,
88 * "height": 400,
89 * "labels": [
90 * "Red",
91 * "Stem"
92 * ],
93 * "_createdDate": "Tues January 22 2019 12:56:02 GMT+0300",
94 * "_updatedDate": "Thurs March 11 2021 05:44:20 GMT+0300"
95 * }]
96 */
97
98
99