From 8c1f07b73e3ffc1462dd2ffe43c21398fc1d59b9 Mon Sep 17 00:00:00 2001 From: Vitalii Date: Fri, 9 Jun 2023 16:44:46 +0300 Subject: [PATCH] web/satellite: fix download in object browser Fixed download objects in object browser. Context: aws-sdk v3 getSignedURL method now returns a Promise instead of regular string. So we have to await for promise to resolve Issue: https://github.com/storj/storj/issues/5956 Change-Id: I2431095e7e8cd1bbc4e866c6958a2c03898c4b4d --- web/satellite/src/components/browser/FileEntry.vue | 4 ++-- .../src/components/browser/galleryView/GalleryView.vue | 4 ++-- web/satellite/src/components/modals/ObjectDetailsModal.vue | 4 ++-- web/satellite/src/store/modules/objectBrowserStore.ts | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/web/satellite/src/components/browser/FileEntry.vue b/web/satellite/src/components/browser/FileEntry.vue index 677eba134..02ed7c73d 100644 --- a/web/satellite/src/components/browser/FileEntry.vue +++ b/web/satellite/src/components/browser/FileEntry.vue @@ -440,9 +440,9 @@ function openDropdown(): void { /** * Download the current file. */ -function download(): void { +async function download(): Promise { try { - obStore.download(props.file); + await obStore.download(props.file); notify.warning('Do not share download link with other people. If you want to share this data better use "Share" option.'); } catch (error) { notify.error('Can not download your file', AnalyticsErrorEventSource.FILE_BROWSER_ENTRY); diff --git a/web/satellite/src/components/browser/galleryView/GalleryView.vue b/web/satellite/src/components/browser/galleryView/GalleryView.vue index 3c52cd845..5a9084ab0 100644 --- a/web/satellite/src/components/browser/galleryView/GalleryView.vue +++ b/web/satellite/src/components/browser/galleryView/GalleryView.vue @@ -279,9 +279,9 @@ async function onDelete(): Promise { /** * Download the current opened file. */ -function download(): void { +async function download(): Promise { try { - obStore.download(file.value); + await obStore.download(file.value); notify.warning('Do not share download link with other people. If you want to share this data better use "Share" option.'); } catch (error) { notify.error('Can not download your file', AnalyticsErrorEventSource.OBJECT_DETAILS_MODAL); diff --git a/web/satellite/src/components/modals/ObjectDetailsModal.vue b/web/satellite/src/components/modals/ObjectDetailsModal.vue index b693cc00d..25cf3c5c5 100644 --- a/web/satellite/src/components/modals/ObjectDetailsModal.vue +++ b/web/satellite/src/components/modals/ObjectDetailsModal.vue @@ -261,9 +261,9 @@ async function fetchPreviewAndMapUrl(): Promise { /** * Download the current opened file. */ -function download(): void { +async function download(): Promise { try { - obStore.download(file.value); + await obStore.download(file.value); notify.warning('Do not share download link with other people. If you want to share this data better use "Share" option.'); } catch (error) { notify.error('Can not download your file', AnalyticsErrorEventSource.OBJECT_DETAILS_MODAL); diff --git a/web/satellite/src/store/modules/objectBrowserStore.ts b/web/satellite/src/store/modules/objectBrowserStore.ts index c373c060b..20bd700b1 100644 --- a/web/satellite/src/store/modules/objectBrowserStore.ts +++ b/web/satellite/src/store/modules/objectBrowserStore.ts @@ -689,14 +689,14 @@ export const useObjectBrowserStore = defineStore('objectBrowser', () => { clearAllSelectedFiles(); } - function download(file): void { + async function download(file): Promise { assertIsInitialized(state); - const url = getSignedUrl(state.s3, new GetObjectCommand({ + const url = await getSignedUrl(state.s3, new GetObjectCommand({ Bucket: state.bucket, Key: state.path + file.Key, })); - const downloadURL = function(data, fileName) { + const downloadURL = function(data: string, fileName: string) { const a = document.createElement('a'); a.href = data; a.download = fileName;