Setup

To use the Media API, install the @wix/media package using npm or Yarn:

Copy
1
npm install @wix/media

or

Copy
1
yarn add @wix/media

Then import media from @wix/media:

Copy
1
import media from '@wix/media'
Was this helpful?
Yes
No

Introduction

 

Developer Preview
APIs in Developer Preview are subject to change and are not intended for use in production.
Send us your suggestions for improving this API. Your feedback is valuable to us.

 

The Wix Media API provides the functionality to manage media files and folders in a site's Media Manager. Learn more about Wix Media.

With the Wix Media API, you can:

  • Manage folders and files in your Media Manager.
  • Generate URLs for uploading files and downloading files and folders.

Learn more about the Media Manager and how to access it.

Terminology

System folders: Folders in the Media Manager's file system directory. There are 3 types of system folders:

  • Root Folders: Main categories of folders the Media Manager.
    • MEDIA_ROOT: Contains all files and folders in the Media Manager's 'Site Files' tab in the UI.
    • TRASH_ROOT: Contains all files and folders in the Media Manager's 'Trash' tab in the UI.
    • VISITOR_UPLOADS_ROOT: Contains all files and folders created by site visitors or members.

    Notes:

    • The MEDIA_ROOT system folder is different from the media-root folder of the Media Manager. The MEDIA_ROOT system folder contains all media in all levels of the 'Site Files' tab in the UI, while the media-root folder of the Media Manager contains only the media in the root level of the 'Site Files' tab in the UI. Similar relationships exist between TRASH_ROOT and trash-root, and VISITOR_UPLOADS_ROOT and visitor-uploads.
    • The VISITOR_UPLOADS_ROOT folder is located in the 'Site Files' tab in the UI. However, it is its own root folder and isn't returned when searching in the MEDIA_ROOT folder.
  • Virtual Folders: Special categories of folders in the Media Manager that are hidden from the UI and can't be deleted.
    • MOBILE_UPLOADS: Contains all media uploaded using mobile devices.
    • PURCHASED_ITEMS: Contains all media imported using a purchase flow.
  • Other Folders:
    • VIDEO_MAKER: Contains all videos created using Wix Video Maker. Located in the 'Site Files' tab in the UI.
Was this helpful?
Yes
No

File ID

A file's ID is its unique identifier. It is a read-only property.

It's good practice to save all of a file's properties in your code when you retrieve them.

A file's ID must be retrieved programmatically. It can't be retrieved through the editor or media manager. There are several functions that include fileId in their response:

Folder ID

A folder's ID is its unique identifier. It is a read-only property.

A folder's ID must be retrieved programmatically. It can't be retrieved through the editor or media manager. There are several functions that include folderId in their response:

Parent Folder ID

A file's or folder's parent folder ID tells us in which folder it is located. Usually, a parent folder ID will be a string of random letters and number, for example '7984b3c5454e4371aqbd4f4eedde96bc'. However, there are 3 parent folders whose IDs look different (these are their IDs):

  • 'media-root' - this folder contains all files and folders in the root level of the Site Files tab in the media manager.
  • 'visitor-uploads' - this folder contains all files and folders in the root level of the Visitor Uploads tab in the media manager.
  • 'trash-root' - this folder contains all files and folders in the root level of the Trash tab in the media manager.
Was this helpful?
Yes
No