the code
for document download
import wixData from 'wix-data';
import wixLocation from 'wix-location';
​
$w.onReady(function () {
});
​
//This one is for Repeater Download with Name from Database Label
export function downloadButton_click(event, $w) {
let repeaterData = $w("#repeater1").data;
let $repeaterData = $w.at(event.context);
let source = $repeaterData("#linkSource").link;
let name = $w("#docName").text;
let url = source.split("/")[3];
wixLocation.to(`https://docs.wixstatic.com/ugd/${url}?dn=${name}.pdf`);
}
//This one is for Repeater Download with Name from Wix Dashboard Media Manager
export function downloadB_click(event, $w) {
let repeaterData = $w("#repeater2").data;
let $repeaterData = $w.at(event.context);
let source = $repeaterData("#linkB").link;
let name = source.split("/")[4];
let url = source.split("/")[3];
wixLocation.to(`https://docs.wixstatic.com/ugd/${url}?dn=${name}.pdf`);
}
//This one is for Table Download with Name from Database Label
export function table1_rowSelect(event, $w) {
tableDownload(event, $w);
$w("#dataset1").refresh();
}
function tableDownload (event, $w){
$w("#table1").onRowSelect( () => {
let rowData = event.rowData;
} );
$w("#dataset1").onCurrentIndexChanged( () => {
let itemData = $w("#dataset1").getCurrentItem();
let name = itemData.title;
let file = itemData.file;
let url = file.split("/")[3];
wixLocation.to(`https://docs.wixstatic.com/ugd/${url}?dn=${name}.pdf`);
});
}