Fix SSE, KMS not encrypting files

This commit is contained in:
2025-12-03 10:03:29 +08:00
parent 804f46d11e
commit 453ac6ea30
8 changed files with 136 additions and 32 deletions

View File

@@ -2850,18 +2850,51 @@
if (!presignLink?.value) {
return;
}
try {
await navigator.clipboard.writeText(presignLink.value);
// Helper function for fallback copy
const fallbackCopy = (text) => {
const textArea = document.createElement('textarea');
textArea.value = text;
textArea.style.position = 'fixed';
textArea.style.left = '-999999px';
textArea.style.top = '-999999px';
document.body.appendChild(textArea);
textArea.focus();
textArea.select();
let success = false;
try {
success = document.execCommand('copy');
} catch (err) {
success = false;
}
textArea.remove();
return success;
};
let copied = false;
// Try modern clipboard API first
if (navigator.clipboard && window.isSecureContext) {
try {
await navigator.clipboard.writeText(presignLink.value);
copied = true;
} catch (error) {
// Fall through to fallback
}
}
// Fallback for non-secure contexts
if (!copied) {
copied = fallbackCopy(presignLink.value);
}
if (copied) {
copyPresignLink.textContent = 'Copied!';
window.setTimeout(() => {
copyPresignLink.textContent = copyPresignDefaultLabel;
}, 1500);
} catch (error) {
if (window.showToast) {
window.showToast('Unable to copy link to clipboard.', 'Copy failed', 'warning');
} else {
alert('Unable to copy link to clipboard.');
}
} else {
showMessage({ title: 'Copy Failed', body: 'Unable to copy link to clipboard. Please select the link and copy manually.', variant: 'warning' });
}
});
@@ -3229,11 +3262,7 @@
window.URL.revokeObjectURL(url);
a.remove();
} catch (error) {
if (window.showToast) {
window.showToast(error.message, 'Download Failed', 'error');
} else {
alert(error.message);
}
showMessage({ title: 'Download Failed', body: error.message, variant: 'danger' });
} finally {
bulkDownloadButton.disabled = false;
bulkDownloadButton.innerHTML = originalHtml;