viewer: fix download of lp video

Signed-off-by: Varun Patil <radialapps@gmail.com>
pull/969/head
Varun Patil 2023-12-09 21:30:07 -08:00
parent 7b603cd095
commit 3165beaacb
2 changed files with 13 additions and 7 deletions

View File

@ -1077,7 +1077,7 @@ export default defineComponent({
async downloadCurrentLiveVideo() { async downloadCurrentLiveVideo() {
const photo = this.currentPhoto; const photo = this.currentPhoto;
if (!photo) return; if (!photo) return;
window.location.href = utils.getLivePhotoVideoUrl(photo, false); dav.downloadFromUrl(utils.getLivePhotoVideoUrl(photo, false));
}, },
/** /**

View File

@ -22,21 +22,27 @@ export async function downloadFiles(fileIds: number[]) {
downloadWithHandle(res.data.handle); downloadWithHandle(res.data.handle);
} }
/** Get URL to download one file (e.g. for video streaming) */
export function getDownloadLink(photo: IPhoto) {
return API.STREAM_FILE(photo.fileid);
}
/** /**
* Download files with a download handle * Download files with a download handle
* @param handle Download handle * @param handle Download handle
*/ */
export function downloadWithHandle(handle: string) { export function downloadWithHandle(handle: string) {
const url = API.DOWNLOAD_FILE(handle); return downloadFromUrl(API.DOWNLOAD_FILE(handle));
}
/**
* Download files from a URL.
* @param url URL to download from
*/
export function downloadFromUrl(url: string) {
// Hand off to download manager (absolute URL) // Hand off to download manager (absolute URL)
if (nativex.has()) return nativex.downloadFromUrl(url); if (nativex.has()) return nativex.downloadFromUrl(url);
// Fallback to browser download // Fallback to browser download
window.location.href = url; window.location.href = url;
} }
/** Get URL to download one file (e.g. for video streaming) */
export function getDownloadLink(photo: IPhoto) {
return API.STREAM_FILE(photo.fileid);
}