Search.../

getFileDescriptor( )

Gets information about the specified file in the Media Manager.

Description

The getFileDescriptor() function returns a Promise that resolves to the specified file's descriptor.

Use getFileDescriptors() to get multiple file descriptors at once.

Admin Method

This function requires elevated permissions to run. This function is not universal and runs only on the backend.

Syntax

function getFileDescriptor(fileId: string): Promise<FileDescriptor>

getFileDescriptor Parameters

NAME
TYPE
DESCRIPTION
fileId
string

File ID.

Returns

Information about the file.

Return Type:

Promise<
FileDescriptor
>
NAME
TYPE
DESCRIPTION
_createdDate
Date

Date and time the file was created.

_id
string

File ID. Generated when a file is uploaded to the Media Manager.

_updatedDate
Date

Date and time the file was updated.

displayName
string

File name as it appears in the Media Manager.

hash
string

File hash.

labels
Array<
string
>

Labels assigned to media files that describe and categorize them. Provided by the user, or generated by Google Vision API for images.

media
FileMedia

Media file content.

mediaType
string

Media file type.

Supported values: "IMAGE", "VIDEO", "AUDIO", "DOCUMENT", "VECTOR", "ARCHIVE", "MODEL3D"

operationStatus
string

Status of the file that was uploaded.

Supported values: "FAILED", "READY", "PENDING"

  • FAILED: The file failed to upload, for example, during media post processing.
  • READY: The file uploaded, finished all processing, and is ready for use.
  • PENDING: The file is processing and the URLs are not yet available. This response is returned when importing a file.
parentFolderId
string

ID of the file's parent folder.

private
boolean

Whether the link to the uploaded file is public or private. Private links require a token.

siteId
string

The Wix site ID where the media file is stored.

sizeInBytes
string

Size of the uploaded file in bytes.

sourceUrl
string

URL where the file was uploaded from.

state
string

State of the file.

Supported values: "OK", "DELETED"

thumbnailUrl
string

URL of the file's thumbnail.

url
string

Static URL of the file.

Was this helpful?

Get a file descriptor (dashboard page code)

Copy Code
1import { files } from 'wix-media.v2';
2
3/* Sample fileId value: 'w8ide0_989yy3iic89mi8880kq9jkr9x7nxiz7l~mv2.jpg' */
4
5async function myGetFileDescriptorFunction(fileId) {
6 try {
7 const descriptor = await files.getFileDescriptor(fileId);
8
9 console.log('Retrieved descriptor:', descriptor);
10 return descriptor;
11 } catch (error) {
12 console.error(error);
13 // Handle the error
14 }
15}
16
17/* Promise resolves to:
18 * {
19 * "_createdDate": "2023-07-23T10:33:00.000Z",
20 * "_id": "w8ide0_989yy3iic89mi8880kq9jkr9x7nxiz7l~mv2.jpg",
21 * "_updatedDate": "2023-07-23T10:33:00.000Z",
22 * "displayName": "example.jpg",
23 * "hash": "x5bq2o4p8fj68xqt25v49wdnasys04xe",
24 * "internalTags": [],
25 * "labels": [],
26 * "media": {
27 * "image": {
28 * "faces": [],
29 * "image": "wix:image://v1/w8ide0_989yy3iic89mi8880kq9jkr9x7nxiz7l~mv2.jpg/example.jpg"
30 * }
31 * },
32 * "mediaType": "IMAGE",
33 * "operationStatus": "READY",
34 * "parentFolderId": "igje5u22nij3qkltzsnol37j3dnthvvh",
35 * "private": false,
36 * "siteId": "3ecba886-4267-11ee-be56-0242ac120002",
37 * "sizeInBytes": "47177",
38 * "sourceUrl": "https://example.org/filename.jpg",
39 * "state": "OK",
40 * "thumbnailUrl": "https://static.wixstatic.com/media/w8ide0_989yy3iic89mi8880kq9jkr9x7nxiz7l~mv2.jpg",
41 * "url": "https://static.wixstatic.com/media/w8ide0_989yy3iic89mi8880kq9jkr9x7nxiz7l~mv2.jpg"
42 * }
43 */
Get a file descriptor (export from backend code)

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { files } from 'wix-media.v2';
3import { elevate } from 'wix-auth';
4
5// Sample fileId value: 'w8ide0_989yy3iic89mi8880kq9jkr9x7nxiz7l~mv2.jpg'
6
7export const myGetFileDescriptorFunction = webMethod(Permissions.Anyone, async (fileId) => {
8 try {
9 const elevatedGetFileDescriptor = elevate(files.getFileDescriptor);
10 const descriptor = await elevatedGetFileDescriptor(fileId);
11
12 console.log('Retrieved descriptor:', descriptor);
13 return descriptor;
14 } catch (error) {
15 console.error(error);
16 // Handle the error
17 }
18});
19
20/* Promise resolves to:
21 * {
22 * "_createdDate": "2023-07-23T10:33:00.000Z",
23 * "_id": "w8ide0_989yy3iic89mi8880kq9jkr9x7nxiz7l~mv2.jpg",
24 * "_updatedDate": "2023-07-23T10:33:00.000Z",
25 * "displayName": "example.jpg",
26 * "hash": "x5bq2o4p8fj68xqt25v49wdnasys04xe",
27 * "internalTags": [],
28 * "labels": [],
29 * "media": {
30 * "image": {
31 * "faces": [],
32 * "image": "wix:image://v1/w8ide0_989yy3iic89mi8880kq9jkr9x7nxiz7l~mv2.jpg/example.jpg"
33 * }
34 * },
35 * "mediaType": "IMAGE",
36 * "operationStatus": "READY",
37 * "parentFolderId": "igje5u22nij3qkltzsnol37j3dnthvvh",
38 * "private": false,
39 * "siteId": "3ecba886-4267-11ee-be56-0242ac120002",
40 * "sizeInBytes": "47177",
41 * "sourceUrl": "https://example.org/filename.jpg",
42 * "state": "OK",
43 * "thumbnailUrl": "https://static.wixstatic.com/media/w8ide0_989yy3iic89mi8880kq9jkr9x7nxiz7l~mv2.jpg",
44 * "url": "https://static.wixstatic.com/media/w8ide0_989yy3iic89mi8880kq9jkr9x7nxiz7l~mv2.jpg"
45 * }
46 */
47