Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Add guard in StorageExplorerStore copyFileURLToClipboard

Joshen Lim9604fb163b34
diff --git a/studio/localStores/storageExplorer/StorageExplorerStore.js b/studio/localStores/storageExplorer/StorageExplorerStore.js
index 071cdeb1c91..3241b0e02c4 100644
--- a/studio/localStores/storageExplorer/StorageExplorerStore.js
+++ b/studio/localStores/storageExplorer/StorageExplorerStore.js
@@ -404,31 +404,39 @@ class StorageExplorerStore {
// Already generated signed URL
copyToClipboard(filePreview.url, () => {
this.ui.setNotification({
- message: `Copied URL for ${file.name} to clipboard.`,
category: 'success',
+ message: `Copied URL for ${file.name} to clipboard.`,
duration: 4000,
})
})
} else {
// Need to generate signed URL, and might as well save it to cache as well
const signedUrl = await this.fetchFilePreview(file.name)
- let formattedUrl = new URL(signedUrl)
- formattedUrl.searchParams.set('t', new Date().toISOString())
- copyToClipboard(formattedUrl.toString(), () => {
+ try {
+ let formattedUrl = new URL(signedUrl)
+ formattedUrl.searchParams.set('t', new Date().toISOString())
+
+ copyToClipboard(formattedUrl.toString(), () => {
+ this.ui.setNotification({
+ category: 'success',
+ message: `Copied URL for ${file.name} to clipboard.`,
+ duration: 4000,
+ })
+ })
+ const fileCache = {
+ id: file.id,
+ url: formattedUrl.toString(),
+ expiresIn: DEFAULT_EXPIRY,
+ fetchedAt: Date.now(),
+ }
+ this.addFileToPreviewCache(fileCache)
+ } catch (error) {
this.ui.setNotification({
- message: `Copied URL for ${file.name} to clipboard.`,
- category: 'success',
- duration: 4000,
+ category: 'error',
+ message: `Failed to copy URL: ${error}`,
})
- })
- const fileCache = {
- id: file.id,
- url: formattedUrl.toString(),
- expiresIn: DEFAULT_EXPIRY,
- fetchedAt: Date.now(),
}
- this.addFileToPreviewCache(fileCache)
}
}