Search.../

downloadFolder( )

Returns a download URL for downloading a folder from the Media Manager.

Description

The downloadFolder() function returns a Promise that resolves to a download URL for a Media Manager folder's files and sub-folders.

A compressed file is created and can be downloaded using the download URL. The compressed file can contain up to 1000 files. Sub-folders are included. The name of the top-level folder requested for download isn't included.

Call the wix-location.to() function with the returned download URL as the external web address. This opens the Download bar in your browser.

This function provides a permanent URL for downloading a folder. To get a temporary download URL for a single file, use the getDownloadUrl() function.

Syntax

function downloadFolder(folderId: string): Promise<string>

downloadFolder Parameters

NAME
TYPE
DESCRIPTION
folderId
string

The ID of the folder to download. You can get the ID with the folderId property of the listFolders() function.

Returns

Fulfilled - The download URL of the folder. You can pass this URL to the wix-location.to() function to open the Download bar in the browser.

Return Type:

Promise<string>

Was this helpful?

Get a download URL for a folder's contents

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { mediaManager } from 'wix-media-backend';
3
4/* Sample folderId value:
5 * '0abec0_bed6f8efb53348379b2011514254e954'
6 */
7
8export const myDownloadFolderFunction = webMethod(Permissions.Anyone, (folderId) => {
9 return mediaManager.downloadFolder(folderId)
10 .then((downloadUrl) => {
11 return downloadUrl;
12 })
13 .catch((error) => {
14 console.error(error);
15 });
16});
17
18/* Promise resolves to a download URL similar to:
19 * 'https://archive.wixmp.com/archive/wix/2d8d9ffc016c443387e42abf8e459c66'
20 */