> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # Method name: generateFilesDownloadUrl(fileIds: Array) # Method package: wixMediaV2 # Method menu location: wixMediaV2 --> files --> generateFilesDownloadUrl # Method Link: https://dev.wix.com/docs/velo/apis/wix-media-v2/files/generate-files-download-url.md # Method Description: Generates a URL for downloading a compressed file containing specific files in the Media Manager. The compressed file can contain up to 1000 files. To generate a permanent URL for downloading a compressed file that contains multiple files in the Media Manager, call the Generate Files Download URL endpoint. Since this is a permanent URL, it is less secure. Therefore, to download private files, call the Generate File Download URL endpoint for each private file that you want to generate a download URL for. # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## Generate a download url for multiple files (dashboard page code) ```javascript import { files } from 'wix-media.v2'; /* Sample fileIds value: * [ * 'd4dde1_dee18c9ada174a818ccf75c50e72c739~mv2.jpg', * 'd4dde1_84a62b7aeb874f73a7b736cad663d6f2.pdf', * 'd4dde1_e26da94b5cb440649ede0c433425449c~mv2.jpg' * ] */ async function myGenerateFilesDownloadUrlFunction(fileIds) { try { const generatedUrl = await files.generateFilesDownloadUrl(fileIds); const url = generatedUrl.downloadUrl; return url; } catch (error) { console.error(error); // Handle the error } } /* Promise resolves to: * { * "downloadUrl": "https://archive.wixmp.com/archive/wix/38f69e35c283495187e85be0c8c06caf" * } */ ``` ## Generate a download url for multiple files (export from backend code) ```javascript import { Permissions, webMethod } from 'wix-web-module'; import { files } from 'wix-media.v2'; import { elevate } from 'wix-auth'; /* Sample fileIds value: * [ * 'd4dde1_dee18c9ada174a818ccf75c50e72c739~mv2.jpg', * 'd4dde1_84a62b7aeb874f73a7b736cad663d6f2.pdf', * 'd4dde1_e26da94b5cb440649ede0c433425449c~mv2.jpg' * ] */ export const myGenerateFilesDownloadUrlFunction = webMethod(Permissions.Anyone, async (fileIds) => { try { const elevatedGenerateFilesDownloadUrl = elevate(files.generateFilesDownloadUrl) const generatedUrl = await elevatedGenerateFilesDownloadUrl(fileIds); const url = generatedUrl.downloadUrl; return url; } catch (error) { console.error(error); // Handle the error } }); /* Promise resolves to: * { * "downloadUrl": "https://archive.wixmp.com/archive/wix/38f69e35c283495187e85be0c8c06caf" * } */ ``` ## Generate a download url for all images in media ```javascript /******************************************** * Backend code - download-files-url.web.js * *******************************************/ import { Permissions, webMethod } from 'wix-web-module'; import { files } from 'wix-media.v2'; import { elevate } from 'wix-auth'; export const generateDownloadUrl = webMethod(Permissions.Anyone, async (fileIds) => { try { const elevatedGenerateFilesDownloadUrl = elevate(files.generateFilesDownloadUrl) const generatedUrl = await elevatedGenerateFilesDownloadUrl(fileIds); return generatedUrl.downloadUrl; } catch (error) { console.error(error); } }); export const listImages = webMethod(Permissions.Anyone, async () => { const listOptions = { mediaTypes: ["IMAGE"] } try { const elevatedListFiles = elevate(files.listFiles) const images = await elevatedListFiles(listOptions); return images.files; } catch (error) { console.error(error); } }); /************* * Page code * ************/ import { listImages, generateDownloadUrl } from 'backend/download-files-url.web'; $w.onReady(() => { $w('#downloadFiles').disable(); getDownloadUrl(); }); async function getDownloadUrl() { const images = await listImages(); const imageIds = images.map((image) => { return image._id; }); const downloadUrl = await generateDownloadUrl(imageIds); $w('#downloadFiles').link = downloadUrl; await $w('#downloadFiles').enable(); } ``` ---