Search...
getFileDescriptors( )
Gets information about the specified files in the Media Manager.
Description
The getFileDescriptors()
function returns a Promise that resolves to an array containing the specified files' descriptors.
Use getFileDescriptor()
to get a single file descriptor.
Admin Method
This function requires elevated permissions to run. This function is not universal and runs only on the backend.
Syntax
function getFileDescriptors(fileIds: Array<string>): Promise<GetFileDescriptorsResponse>
getFileDescriptors Parameters
NAME
TYPE
DESCRIPTION
fileIds
Array<
string
>File IDs.
Returns
Return Type:
Promise<
GetFileDescriptorsResponse
>NAME
TYPE
DESCRIPTION
files
Array<
FileDescriptor
>Information about the requested files.
Was this helpful?
Get file descriptors (dashboard page code)
Copy Code
1import { files } from 'wix-media.v2';23/* Sample fileIds value:4 * [5 * 'w8ide0_87051wjiadg6qj2ywxb07vn5snqxxp2q',6 * 'w8ide0_mnk3lozhxu0w4f1g5wuusmwqedox2w1p~mv2.jpg',7 * 'w8ide0_578uul37zvr7b6d7ji3cbm91rlf5dvjy.zip'8 * ]9 */1011async function myGetFileDescriptorsFunction(fileIds) {12 try {13 const descriptors = await files.getFileDescriptors(fileIds);1415 console.log('Retrieved descriptors:', descriptors);16 return descriptors;17 } catch (error) {18 console.error(error);19 // Handle the error20 }21}2223/* Promise resolves to:24 * {25 * "files": [26 * {27 * "_createdDate": "2023-07-23T09:05:12.000Z",28 * "_id": "w8ide0_mnk3lozhxu0w4f1g5wuusmwqedox2w1p~mv2.jpg",29 * "_updatedDate": "2023-07-23T09:05:12.000Z",30 * "displayName": "image1.jpg",31 * "hash": "d7ltmbrrmdspiyrw3db29bpi1g8lsacz",32 * "internalTags": [],33 * "labels": [],34 * "media": {35 * "image": {36 * "faces": [],37 * "image": "wix:image://v1/w8ide0_mnk3lozhxu0w4f1g5wuusmwqedox2w1p~mv2.jpg/image1.jpg#originWidth=1000&originHeight=714"38 * }39 * },40 * "mediaType": "IMAGE",41 * "operationStatus": "READY",42 * "parentFolderId": "media-root",43 * "private": false,44 * "siteId": "3ecba886-4267-11ee-be56-0242ac120002",45 * "sizeInBytes": "112689",46 * "sourceUrl": "https://website.org/image1.jpg",47 * "state": "OK",48 * "thumbnailUrl": "https://static.wixstatic.com/media/w8ide0_mnk3lozhxu0w4f1g5wuusmwqedox2w1p~mv2.jpg",49 * "url": "https://static.wixstatic.com/media/w8ide0_mnk3lozhxu0w4f1g5wuusmwqedox2w1p~mv2.jpg"50 * },51 * {52 * "_createdDate": "2023-07-16T08:56:10.000Z",53 * "_id": "w8ide0_578uul37zvr7b6d7ji3cbm91rlf5dvjy.zip",54 * "_updatedDate": "2023-07-20T07:16:55.000Z",55 * "displayName": "pics",56 * "hash": "tmk0uafvzzgkddrgwgl6od1h9jsp1j9e",57 * "internalTags": [58 * "_fileOrigin_uploaded"59 * ],60 * "labels": [],61 * "media": {62 * "archive": {63 * "_id": "w8ide0_578uul37zvr7b6d7ji3cbm91rlf5dvjy.zip",64 * "filename": "riverpics",65 * "sizeInBytes": "49546083",66 * "url": "https://3ecba886-4267-11ee-be56-0242ac120002.usrfiles.com/archives/w8ide0_578uul37zvr7b6d7ji3cbm91rlf5dvjy.zip"67 * }68 * },69 * "mediaType": "ARCHIVE",70 * "operationStatus": "READY",71 * "parentFolderId": "media-root",72 * "private": false,73 * "siteId": "3ecba886-4267-11ee-be56-0242ac120002",74 * "sizeInBytes": "49546083",75 * "state": "OK",76 * "thumbnailUrl": "https://static.wixstatic.com/media/48c4fbc47d7298cd4406936294b4c532.png",77 * "url": "https://3ecba886-4267-11ee-be56-0242ac120002.usrfiles.com/archives/w8ide0_578uul37zvr7b6d7ji3cbm91rlf5dvjy.zip"78 * },79 * {80 * "_createdDate": "2023-07-23T12:15:55.000Z",81 * "_id": "w8ide0_87051wjiadg6qj2ywxb07vn5snqxxp2q",82 * "_updatedDate": "2023-07-23T12:16:14.000Z",83 * "displayName": "video1.mp4",84 * "hash": "pdrepnjy3cdjq8bt2lzmpdvuc47mm921",85 * "internalTags": [],86 * "labels": [],87 * "media": {88 * "video": "wix:video://v1/w8ide0_87051wjiadg6qj2ywxb07vn5snqxxp2q/video1.mp4#posterUri=w8ide0_87051wjiadg6qj2ywxb07vn5snqxxp2qf001.jpg&posterWidth=1280&posterHeight=720"89 * },90 * "mediaType": "VIDEO",91 * "operationStatus": "READY",92 * "parentFolderId": "media-root",93 * "private": false,94 * "siteId": "3ecba886-4267-11ee-be56-0242ac120002",95 * "sizeInBytes": "4384468",96 * "sourceUrl": "https://cdn.pixabay.com/example.mp4",97 * "state": "OK",98 * "thumbnailUrl": "https://static.wixstatic.com/media/w8ide0_87051wjiadg6qj2ywxb07vn5snqxxp2qf002.jpg",99 * "url": "https://video.wixstatic.com/video/w8ide0_87051wjiadg6qj2ywxb07vn5snqxxp2q/file"100 * }101 * ]102 * }103 */
Get file descriptors (export from backend code)
Copy Code
1import { Permissions, webMethod } from 'wix-web-module';2import { files } from 'wix-media.v2';3import { elevate } from 'wix-auth';45/* Sample fileIds value:6 * [7 * 'w8ide0_87051wjiadg6qj2ywxb07vn5snqxxp2q',8 * 'w8ide0_mnk3lozhxu0w4f1g5wuusmwqedox2w1p~mv2.jpg',9 * 'w8ide0_578uul37zvr7b6d7ji3cbm91rlf5dvjy.zip'10 * ]11 */1213export const myGetFileDescriptorsFunction = webMethod(Permissions.Anyone, async (fileIds) => {14 try {15 const elevatedGetFileDescriptors = elevate(files.getFileDescriptors);16 const descriptors = await elevatedGetFileDescriptors(fileIds);1718 console.log('Retrieved descriptors:', descriptors);19 return descriptors;20 } catch (error) {21 console.error(error);22 // Handle the error23 }24});2526/* Promise resolves to:27 * {28 * "files": [29 * {30 * "_createdDate": "2023-07-23T09:05:12.000Z",31 * "_id": "w8ide0_mnk3lozhxu0w4f1g5wuusmwqedox2w1p~mv2.jpg",32 * "_updatedDate": "2023-07-23T09:05:12.000Z",33 * "displayName": "image1.jpg",34 * "hash": "d7ltmbrrmdspiyrw3db29bpi1g8lsacz",35 * "internalTags": [],36 * "labels": [],37 * "media": {38 * "image": {39 * "faces": [],40 * "image": "wix:image://v1/w8ide0_mnk3lozhxu0w4f1g5wuusmwqedox2w1p~mv2.jpg/image1.jpg#originWidth=1000&originHeight=714"41 * }42 * },43 * "mediaType": "IMAGE",44 * "operationStatus": "READY",45 * "parentFolderId": "media-root",46 * "private": false,47 * "siteId": "3ecba886-4267-11ee-be56-0242ac120002",48 * "sizeInBytes": "112689",49 * "sourceUrl": "https://website.org/image1.jpg",50 * "state": "OK",51 * "thumbnailUrl": "https://static.wixstatic.com/media/w8ide0_mnk3lozhxu0w4f1g5wuusmwqedox2w1p~mv2.jpg",52 * "url": "https://static.wixstatic.com/media/w8ide0_mnk3lozhxu0w4f1g5wuusmwqedox2w1p~mv2.jpg"53 * },54 * {55 * "_createdDate": "2023-07-16T08:56:10.000Z",56 * "_id": "w8ide0_578uul37zvr7b6d7ji3cbm91rlf5dvjy.zip",57 * "_updatedDate": "2023-07-20T07:16:55.000Z",58 * "displayName": "pics",59 * "hash": "tmk0uafvzzgkddrgwgl6od1h9jsp1j9e",60 * "internalTags": [61 * "_fileOrigin_uploaded"62 * ],63 * "labels": [],64 * "media": {65 * "archive": {66 * "_id": "w8ide0_578uul37zvr7b6d7ji3cbm91rlf5dvjy.zip",67 * "filename": "riverpics",68 * "sizeInBytes": "49546083",69 * "url": "https://3ecba886-4267-11ee-be56-0242ac120002.usrfiles.com/archives/w8ide0_578uul37zvr7b6d7ji3cbm91rlf5dvjy.zip"70 * }71 * },72 * "mediaType": "ARCHIVE",73 * "operationStatus": "READY",74 * "parentFolderId": "media-root",75 * "private": false,76 * "siteId": "3ecba886-4267-11ee-be56-0242ac120002",77 * "sizeInBytes": "49546083",78 * "state": "OK",79 * "thumbnailUrl": "https://static.wixstatic.com/media/48c4fbc47d7298cd4406936294b4c532.png",80 * "url": "https://3ecba886-4267-11ee-be56-0242ac120002.usrfiles.com/archives/w8ide0_578uul37zvr7b6d7ji3cbm91rlf5dvjy.zip"81 * },82 * {83 * "_createdDate": "2023-07-23T12:15:55.000Z",84 * "_id": "w8ide0_87051wjiadg6qj2ywxb07vn5snqxxp2q",85 * "_updatedDate": "2023-07-23T12:16:14.000Z",86 * "displayName": "video1.mp4",87 * "hash": "pdrepnjy3cdjq8bt2lzmpdvuc47mm921",88 * "internalTags": [],89 * "labels": [],90 * "media": {91 * "video": "wix:video://v1/w8ide0_87051wjiadg6qj2ywxb07vn5snqxxp2q/video1.mp4#posterUri=w8ide0_87051wjiadg6qj2ywxb07vn5snqxxp2qf001.jpg&posterWidth=1280&posterHeight=720"92 * },93 * "mediaType": "VIDEO",94 * "operationStatus": "READY",95 * "parentFolderId": "media-root",96 * "private": false,97 * "siteId": "3ecba886-4267-11ee-be56-0242ac120002",98 * "sizeInBytes": "4384468",99 * "sourceUrl": "https://cdn.pixabay.com/example.mp4",100 * "state": "OK",101 * "thumbnailUrl": "https://static.wixstatic.com/media/w8ide0_87051wjiadg6qj2ywxb07vn5snqxxp2qf002.jpg",102 * "url": "https://video.wixstatic.com/video/w8ide0_87051wjiadg6qj2ywxb07vn5snqxxp2q/file"103 * }104 * ]105 * }106 */107