web/satellite: fix download in object browser

Fixed download objects in object browser.

Context:
aws-sdk v3 getSignedURL method now returns a Promise<string> instead of regular string. So we have to await for promise to resolve

Issue:
https://github.com/storj/storj/issues/5956

Change-Id: I2431095e7e8cd1bbc4e866c6958a2c03898c4b4d
This commit is contained in:
Vitalii 2023-06-09 16:44:46 +03:00 committed by Vitalii Shpital
parent 61933bc6f0
commit 8c1f07b73e
4 changed files with 9 additions and 9 deletions

View File

@ -440,9 +440,9 @@ function openDropdown(): void {
/**
* Download the current file.
*/
function download(): void {
async function download(): Promise<void> {
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);

View File

@ -279,9 +279,9 @@ async function onDelete(): Promise<void> {
/**
* Download the current opened file.
*/
function download(): void {
async function download(): Promise<void> {
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);

View File

@ -261,9 +261,9 @@ async function fetchPreviewAndMapUrl(): Promise<void> {
/**
* Download the current opened file.
*/
function download(): void {
async function download(): Promise<void> {
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);

View File

@ -689,14 +689,14 @@ export const useObjectBrowserStore = defineStore('objectBrowser', () => {
clearAllSelectedFiles();
}
function download(file): void {
async function download(file): Promise<void> {
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;