The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Deprecate onCopyFileUrlToClipboard in StorageExplorerStore and add a new function at the UI level to consider custom domains
Joshen Limfd0abadc6da1
diff --git a/studio/components/layouts/StorageLayout/StorageLayout.tsx b/studio/components/layouts/StorageLayout/StorageLayout.tsxindex 797b327ad60..4993b2c015f 100644--- a/studio/components/layouts/StorageLayout/StorageLayout.tsx+++ b/studio/components/layouts/StorageLayout/StorageLayout.tsx@@ -30,7 +30,7 @@ const StorageLayout = ({ title, children }: StorageLayoutProps) => {useEffect(() => {if (!isLoading && apiService) initializeStorageStore(apiService)- }, [isLoading])+ }, [isLoading, projectRef])const initializeStorageStore = async (apiService: AutoApiService) => {if (isPaused) returndiff --git a/studio/components/to-be-cleaned/Storage/Storage.types.ts b/studio/components/to-be-cleaned/Storage/Storage.types.tsnew file mode 100644index 00000000000..fcb2ac2e405--- /dev/null+++ b/studio/components/to-be-cleaned/Storage/Storage.types.ts@@ -0,0 +1,30 @@+export interface StorageColumn {+ id: string+ name: string+ status: string+ items: StorageItem[]+ hasMoreItems: boolean+ isLoadingMoreItems: boolean+}++export interface StorageItem {+ id: string | null+ name: string+ type: string+ status: string+ metadata: StorageItemMetadata | null+ isCorrupted: boolean+ created_at: string | null+ updated_at: string | null+ last_accessed_at: string | null+}++export interface StorageItemMetadata {+ cacheControl: string+ contentLength: number+ size: number+ httpStatusCode: number+ eTag: string+ lastModified: string+ mimetype: string+}diff --git a/studio/components/to-be-cleaned/Storage/StorageExplorer/CustomExpiryModal.tsx b/studio/components/to-be-cleaned/Storage/StorageExplorer/CustomExpiryModal.tsxindex f702ba38bfa..d20d137cdbc 100644--- a/studio/components/to-be-cleaned/Storage/StorageExplorer/CustomExpiryModal.tsx+++ b/studio/components/to-be-cleaned/Storage/StorageExplorer/CustomExpiryModal.tsx@@ -1,14 +1,14 @@-import { FC } from 'react'import { Form, Modal, Input, Button } from 'ui'import { observer } from 'mobx-react-lite'import { useStorageStore } from 'localStores/storageExplorer/StorageExplorerStore'-interface Props {}+export interface CustomExpiryModalProps {+ onCopyUrl: (name: string, url: string) => void+}-const CustomExpiryModal: FC<Props> = () => {+const CustomExpiryModal = ({ onCopyUrl }: CustomExpiryModalProps) => {const storageExplorerStore = useStorageStore()- const { selectedFileCustomExpiry, setSelectedFileCustomExpiry, copyFileURLToClipboard } =- storageExplorerStore+ const { getFileUrl, selectedFileCustomExpiry, setSelectedFileCustomExpiry } = storageExplorerStoreconst visible = selectedFileCustomExpiry !== undefinedconst onClose = () => setSelectedFileCustomExpiry(undefined)@@ -28,7 +28,10 @@ const CustomExpiryModal: FC<Props> = () => {initialValues={{ expiresIn: '' }}onSubmit={async (values: any, { setSubmitting }: any) => {setSubmitting(true)- await copyFileURLToClipboard(selectedFileCustomExpiry, values.expiresIn)+ onCopyUrl(+ selectedFileCustomExpiry.name,+ await getFileUrl(selectedFileCustomExpiry, values.expiresIn)+ )setSubmitting(false)onClose()}}diff --git a/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorer.js b/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorer.tsxsimilarity index 74%rename from studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorer.jsrename to studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorer.tsxindex 2b41ffda51a..09783f3f591 100644--- a/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorer.js+++ b/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorer.tsx@@ -6,6 +6,21 @@ import ItemContextMenu from './ItemContextMenu'import FolderContextMenu from './FolderContextMenu'import ColumnContextMenu from './ColumnContextMenu'import FileExplorerColumn from './FileExplorerColumn'+import { noop } from 'lodash'+import { StorageColumn } from '../Storage.types'++export interface FileExplorerProps {+ view: string+ columns: any[]+ openedFolders: any[]+ selectedItems: any[]+ selectedFilePreview: any+ onFilesUpload: (event: any, index: number) => void+ onSelectAllItemsInColumn: (index: number) => void+ onSelectColumnEmptySpace: (index: number) => void+ onColumnLoadMore: (index: number, column: StorageColumn) => void+ onCopyUrl: (name: string, url: string) => void+}const FileExplorer = ({view = STORAGE_VIEWS.COLUMNS,@@ -13,12 +28,13 @@ const FileExplorer = ({openedFolders = [],selectedItems = [],selectedFilePreview = {},- onFilesUpload = () => {},- onSelectAllItemsInColumn = () => {},- onSelectColumnEmptySpace = () => {},- onColumnLoadMore = () => {},-}) => {- const fileExplorerRef = useRef(null)+ onFilesUpload = noop,+ onSelectAllItemsInColumn = noop,+ onSelectColumnEmptySpace = noop,+ onColumnLoadMore = noop,+ onCopyUrl = noop,+}: FileExplorerProps) => {+ const fileExplorerRef = useRef<any>(null)useEffect(() => {if (fileExplorerRef) {@@ -35,7 +51,7 @@ const FileExplorer = ({className="file-explorer flex flex-grow overflow-x-auto justify-between h-full w-full"><ColumnContextMenu id={CONTEXT_MENU_KEYS.STORAGE_COLUMN} />- <ItemContextMenu id={CONTEXT_MENU_KEYS.STORAGE_ITEM} />+ <ItemContextMenu id={CONTEXT_MENU_KEYS.STORAGE_ITEM} onCopyUrl={onCopyUrl} /><FolderContextMenu id={CONTEXT_MENU_KEYS.STORAGE_FOLDER} />{view === STORAGE_VIEWS.COLUMNS ? (<div className="flex">@@ -52,6 +68,7 @@ const FileExplorer = ({onSelectAllItemsInColumn={onSelectAllItemsInColumn}onSelectColumnEmptySpace={onSelectColumnEmptySpace}onColumnLoadMore={onColumnLoadMore}+ onCopyUrl={onCopyUrl}/>))}</div>@@ -69,6 +86,7 @@ const FileExplorer = ({onSelectAllItemsInColumn={onSelectAllItemsInColumn}onSelectColumnEmptySpace={onSelectColumnEmptySpace}onColumnLoadMore={onColumnLoadMore}+ onCopyUrl={onCopyUrl}/>)}</>diff --git a/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerColumn.js b/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerColumn.tsxsimilarity index 88%rename from studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerColumn.jsrename to studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerColumn.tsxindex 3bf029e8f5f..264deef55a7 100644--- a/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerColumn.js+++ b/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerColumn.tsx@@ -1,5 +1,5 @@import { useState, useRef, useEffect } from 'react'-import { get, sum } from 'lodash'+import { get, noop, sum } from 'lodash'import { Checkbox, IconUpload } from 'ui'import { Transition } from '@headlessui/react'import { useContextMenu } from 'react-contexify'@@ -15,8 +15,9 @@ import {} from '../Storage.constants'import { formatBytes } from 'lib/helpers'import { BASE_PATH } from 'lib/constants'+import { StorageColumn } from '../Storage.types'-const DragOverOverlay = ({ isOpen, onDragLeave, onDrop, folderIsEmpty }) => {+const DragOverOverlay = ({ isOpen, onDragLeave, onDrop, folderIsEmpty }: any) => {return (<Transitionshow={isOpen}@@ -50,21 +51,37 @@ const DragOverOverlay = ({ isOpen, onDragLeave, onDrop, folderIsEmpty }) => {)}+export interface FileExplorerColumnProps {+ index: number+ view: string+ column: StorageColumn+ fullWidth?: boolean+ openedFolders?: any[]+ selectedItems: any[]+ selectedFilePreview: any+ onFilesUpload: (event: any, index: number) => void+ onSelectAllItemsInColumn: (index: number) => void+ onSelectColumnEmptySpace: (index: number) => void+ onColumnLoadMore: (index: number, column: StorageColumn) => void+ onCopyUrl: (name: string, url: string) => void+}+const FileExplorerColumn = ({index = 0,view = STORAGE_VIEWS.COLUMNS,- column = {},+ column,fullWidth = false,openedFolders = [],selectedItems = [],selectedFilePreview = {},- onFilesUpload = () => {},- onSelectAllItemsInColumn = () => {},- onSelectColumnEmptySpace = () => {},- onColumnLoadMore = () => {},-}) => {+ onFilesUpload = noop,+ onSelectAllItemsInColumn = noop,+ onSelectColumnEmptySpace = noop,+ onColumnLoadMore = noop,+ onCopyUrl = noop,+}: FileExplorerColumnProps) => {const [isDraggedOver, setIsDraggedOver] = useState(false)- const fileExplorerColumnRef = useRef(null)+ const fileExplorerColumnRef = useRef<any>(null)useEffect(() => {if (fileExplorerColumnRef) {@@ -87,14 +104,14 @@ const FileExplorerColumn = ({const columnItemsSize = sum(columnItems.map((item) => get(item, ['metadata', 'size'], 0)))const { show } = useContextMenu()- const displayMenu = (event) => {+ const displayMenu = (event: any) => {show(event, {id: CONTEXT_MENU_KEYS.STORAGE_COLUMN,props: { index },})}- const onDragOver = (event) => {+ const onDragOver = (event: any) => {if (event) {event.stopPropagation()event.preventDefault()@@ -104,7 +121,7 @@ const FileExplorerColumn = ({}}- const onDrop = (event) => {+ const onDrop = (event: any) => {onDragOver(event)onFilesUpload(event, index)}@@ -144,7 +161,7 @@ const FileExplorerColumn = ({{view === STORAGE_VIEWS.COLUMNS && (<divclassName={`sticky top-0 z-10 mb-0 flex items-center bg-table-header-light px-2.5 dark:bg-table-header-dark ${- haveSelectedItems > 0 ? 'h-10 py-3 opacity-100' : 'h-0 py-0 opacity-0'+ haveSelectedItems ? 'h-10 py-3 opacity-100' : 'h-0 py-0 opacity-0'} transition-all duration-200`}onClick={(event) => event.stopPropagation()}>@@ -202,15 +219,7 @@ const FileExplorerColumn = ({selectedItems,openedFolders,selectedFilePreview,- // onCheckItem,- // onRenameFile,- // onCopyFileURL,- // onDownloadFile,- // onRenameFolder,- // onCreateFolder,- // onSelectItemDelete,- // onSelectItemRename,- // onSelectItemMove,+ onCopyUrl,}}ItemComponent={FileExplorerRow}getItemSize={(index) => (index !== 0 && index === columnItems.length ? 85 : 37)}diff --git a/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerRow.tsx b/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerRow.tsxindex 95fb39f36ca..19567f7484b 100644--- a/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerRow.tsx+++ b/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerRow.tsx@@ -71,7 +71,7 @@ export const RowIcon = ({ view, status, fileType, mimeType }: any) => {return <IconFile size={16} strokeWidth={2} />}-interface FileExplorerRowProps {+export interface FileExplorerRowProps {index: numberitem: anyview: string@@ -79,6 +79,7 @@ interface FileExplorerRowProps {selectedItems: any[]openedFolders: any[]selectedFilePreview: any+ onCopyUrl: (name: string, url: string) => void}const FileExplorerRow = ({@@ -89,9 +90,11 @@ const FileExplorerRow = ({selectedItems = [],openedFolders = [],selectedFilePreview = {},+ onCopyUrl,}: FileExplorerRowProps) => {const storageExplorerStore = useStorageStore()const {+ getFileUrl,popColumnAtIndex,pushOpenedFolderAtIndex,popOpenedFoldersAtIndex,@@ -107,7 +110,6 @@ const FileExplorerRow = ({fetchFolderContents,downloadFile,downloadFolder,- copyFileURLToClipboard,selectRangeItems,} = storageExplorerStore@@ -188,7 +190,11 @@ const FileExplorerRow = ({{name: 'Get URL',icon: <IconClipboard size="tiny" />,- onClick: async () => await copyFileURLToClipboard(itemWithColumnIndex),+ onClick: async () =>+ onCopyUrl(+ itemWithColumnIndex.name,+ await getFileUrl(itemWithColumnIndex)+ ),},]: [@@ -199,25 +205,25 @@ const FileExplorerRow = ({{name: 'Expire in 1 week',onClick: async () =>- await copyFileURLToClipboard(- itemWithColumnIndex,- URL_EXPIRY_DURATION.WEEK+ onCopyUrl(+ itemWithColumnIndex.name,+ await getFileUrl(itemWithColumnIndex, URL_EXPIRY_DURATION.WEEK)),},{name: 'Expire in 1 month',onClick: async () =>- await copyFileURLToClipboard(- itemWithColumnIndex,- URL_EXPIRY_DURATION.MONTH+ onCopyUrl(+ itemWithColumnIndex.name,+ await getFileUrl(itemWithColumnIndex, URL_EXPIRY_DURATION.MONTH)),},{name: 'Expire in 1 year',onClick: async () =>- await copyFileURLToClipboard(- itemWithColumnIndex,- URL_EXPIRY_DURATION.YEAR+ onCopyUrl(+ itemWithColumnIndex.name,+ await getFileUrl(itemWithColumnIndex, URL_EXPIRY_DURATION.YEAR)),},{diff --git a/studio/components/to-be-cleaned/Storage/StorageExplorer/ItemContextMenu.tsx b/studio/components/to-be-cleaned/Storage/StorageExplorer/ItemContextMenu.tsxindex bd0ad8fec92..e04d39f146c 100644--- a/studio/components/to-be-cleaned/Storage/StorageExplorer/ItemContextMenu.tsx+++ b/studio/components/to-be-cleaned/Storage/StorageExplorer/ItemContextMenu.tsx@@ -1,4 +1,3 @@-import { FC } from 'react'import { observer } from 'mobx-react-lite'import { Menu, Item, Separator, Submenu } from 'react-contexify'import 'react-contexify/dist/ReactContexify.css'@@ -8,21 +7,23 @@ import { IconClipboard, IconEdit, IconMove, IconDownload, IconTrash2, IconChevroimport { checkPermissions } from 'hooks'import { URL_EXPIRY_DURATION } from '../Storage.constants'import { useStorageStore } from 'localStores/storageExplorer/StorageExplorerStore'+import { noop } from 'lodash'-interface Props {+interface ItemContextMenuProps {id: string+ onCopyUrl: (name: string, url: string) => void}-const ItemContextMenu: FC<Props> = ({ id = '' }) => {+const ItemContextMenu = ({ id = '', onCopyUrl = noop }: ItemContextMenuProps) => {const storageExplorerStore = useStorageStore()const {+ getFileUrl,downloadFile,selectedBucket,setSelectedItemsToDelete,setSelectedItemToRename,setSelectedItemsToMove,setSelectedFileCustomExpiry,- copyFileURLToClipboard,} = storageExplorerStoreconst isPublic = selectedBucket.publicconst canUpdateFiles = checkPermissions(PermissionAction.STORAGE_ADMIN_WRITE, '*')@@ -32,7 +33,7 @@ const ItemContextMenu: FC<Props> = ({ id = '' }) => {switch (event) {case 'copy':if (expiresIn !== undefined && expiresIn < 0) return setSelectedFileCustomExpiry(item)- else return await copyFileURLToClipboard(item, expiresIn)+ else return onCopyUrl(item.name, await getFileUrl(item, expiresIn))case 'rename':return setSelectedItemToRename(item)case 'move':diff --git a/studio/components/to-be-cleaned/Storage/StorageExplorer/PreviewPane.tsx b/studio/components/to-be-cleaned/Storage/StorageExplorer/PreviewPane.tsxindex 453825ddeec..cb4deb1bea3 100644--- a/studio/components/to-be-cleaned/Storage/StorageExplorer/PreviewPane.tsx+++ b/studio/components/to-be-cleaned/Storage/StorageExplorer/PreviewPane.tsx@@ -94,13 +94,17 @@ const PreviewFile = ({ mimeType, previewUrl }: { mimeType: string; previewUrl: s)}-const PreviewPane = () => {+export interface PreviewPaneProps {+ onCopyUrl: (name: string, url: string) => void+}++const PreviewPane = ({ onCopyUrl }: PreviewPaneProps) => {const storageExplorerStore = useStorageStore()const {+ getFileUrl,downloadFile,selectedBucket,selectedFilePreview: file,- copyFileURLToClipboard,closeFilePreview,setSelectedItemsToDelete,setSelectedFileCustomExpiry,@@ -194,7 +198,7 @@ const PreviewPane = () => {<Buttontype="outline"icon={<IconClipboard size={16} strokeWidth={2} />}- onClick={async () => await copyFileURLToClipboard(file)}+ onClick={async () => onCopyUrl(file.name, await getFileUrl(file))}disabled={file.isCorrupted}>Get URL@@ -207,7 +211,7 @@ const PreviewPane = () => {<Dropdown.Itemkey="expires-one-week"onClick={async () =>- await copyFileURLToClipboard(file, URL_EXPIRY_DURATION.WEEK)+ onCopyUrl(file.name, await getFileUrl(file, URL_EXPIRY_DURATION.WEEK))}>Expire in 1 week@@ -215,7 +219,7 @@ const PreviewPane = () => {<Dropdown.Itemkey="expires-one-month"onClick={async () =>- await copyFileURLToClipboard(file, URL_EXPIRY_DURATION.MONTH)+ onCopyUrl(file.name, await getFileUrl(file, URL_EXPIRY_DURATION.MONTH))}>Expire in 1 month@@ -223,7 +227,7 @@ const PreviewPane = () => {<Dropdown.Itemkey="expires-one-year"onClick={async () =>- await copyFileURLToClipboard(file, URL_EXPIRY_DURATION.YEAR)+ onCopyUrl(file.name, await getFileUrl(file, URL_EXPIRY_DURATION.YEAR))}>Expire in 1 yeardiff --git a/studio/components/to-be-cleaned/Storage/StorageExplorer/StorageExplorer.js b/studio/components/to-be-cleaned/Storage/StorageExplorer/StorageExplorer.jsindex d07c4eaa3d2..89b977bebe1 100644--- a/studio/components/to-be-cleaned/Storage/StorageExplorer/StorageExplorer.js+++ b/studio/components/to-be-cleaned/Storage/StorageExplorer/StorageExplorer.js@@ -1,17 +1,22 @@-import { useEffect, useState, useRef } from 'react'+import { compact, get, isEmpty, uniqBy } from 'lodash'import { observer } from 'mobx-react-lite'-import { compact, isEmpty, uniqBy, get } from 'lodash'+import { useEffect, useRef, useState } from 'react'+import { useParams } from 'common'import { useStorageStore } from 'localStores/storageExplorer/StorageExplorerStore'import { STORAGE_ROW_TYPES } from '../Storage.constants'-+import ConfirmDeleteModal from './ConfirmDeleteModal'+import CustomExpiryModal from './CustomExpiryModal'import FileExplorer from './FileExplorer'import FileExplorerHeader from './FileExplorerHeader'import FileExplorerHeaderSelection from './FileExplorerHeaderSelection'-import ConfirmDeleteModal from './ConfirmDeleteModal'import MoveItemsModal from './MoveItemsModal'import PreviewPane from './PreviewPane'-import CustomExpiryModal from './CustomExpiryModal'+import { useCustomDomainsQuery } from 'data/custom-domains/custom-domains-query'+import { useProjectSettingsQuery } from 'data/config/project-settings-query'+import { DEFAULT_PROJECT_API_SERVICE_ID } from 'lib/constants'+import { copyToClipboard } from 'lib/helpers'+import { useStore } from 'hooks'const StorageExplorer = observer(({ bucket }) => {const storageExplorerStore = useStorageStore()@@ -44,6 +49,16 @@ const StorageExplorer = observer(({ bucket }) => {const storageExplorerRef = useRef(null)+ const { ui } = useStore()+ const { ref } = useParams()+ const { data: customDomainData } = useCustomDomainsQuery({ projectRef: ref })+ const { data: projectSettings } = useProjectSettingsQuery({ projectRef: ref })+ const apiService = (projectSettings?.services ?? []).find(+ (x) => x.app.id == DEFAULT_PROJECT_API_SERVICE_ID+ )+ const apiConfig = apiService?.app_config+ const apiUrl = `${apiConfig?.protocol ?? 'https'}://${apiConfig?.endpoint ?? '-'}`+// This state exists outside of the header because FileExplorerColumn needs to listen to these as well// I'm keeping them outside of the mobx store as I feel that the store should contain persistent data// Things like showing results from a search filter is "temporary", hence we use react state to manage@@ -150,6 +165,19 @@ const StorageExplorer = observer(({ bucket }) => {clearSelectedItems()}+ const onCopyUrl = (name, url) => {+ const formattedUrl = customDomainData?.customDomain+ ? url.replace(apiUrl, `https://${customDomainData.customDomain.hostname}`)+ : url+ copyToClipboard(formattedUrl, () => {+ ui.setNotification({+ category: 'success',+ message: `Copied URL for ${name} to clipboard.`,+ duration: 4000,+ })+ })+ }+return (<divref={storageExplorerRef}@@ -180,8 +208,9 @@ const StorageExplorer = observer(({ bucket }) => {onColumnLoadMore={(index, column) =>fetchMoreFolderContents(index, column, itemSearchString)}+ onCopyUrl={onCopyUrl}/>- <PreviewPane />+ <PreviewPane onCopyUrl={onCopyUrl} /></div><ConfirmDeleteModalvisible={selectedItemsToDelete.length > 0}@@ -196,7 +225,7 @@ const StorageExplorer = observer(({ bucket }) => {onSelectCancel={clearSelectedItemsToMove}onSelectMove={onMoveSelectedFiles}/>- <CustomExpiryModal />+ <CustomExpiryModal onCopyUrl={onCopyUrl} /></div>)})diff --git a/studio/localStores/storageExplorer/StorageExplorerStore.js b/studio/localStores/storageExplorer/StorageExplorerStore.jsindex 2c30d660945..f0148c926f2 100644--- a/studio/localStores/storageExplorer/StorageExplorerStore.js+++ b/studio/localStores/storageExplorer/StorageExplorerStore.js@@ -394,44 +394,26 @@ class StorageExplorerStore {this.selectedFilePreview = {}}- copyFileURLToClipboard = async (file, expiresIn = 0) => {+ getFileUrl = async (file, expiresIn = 0) => {const filePreview = find(this.filePreviewCache, { id: file.id })if (filePreview !== undefined && expiresIn === 0) {- // Already generated signed URL- copyToClipboard(filePreview.url, () => {- this.ui.setNotification({- category: 'success',- message: `Copied URL for ${file.name} to clipboard.`,- duration: 4000,- })- })+ return filePreview.url} else {- // Need to generate signed URL, and might as well save it to cache as wellconst signedUrl = await this.fetchFilePreview(file.name, expiresIn)const formattedUrl = new URL(signedUrl)formattedUrl.searchParams.set('t', new Date().toISOString())-- try {- 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({- category: 'error',- message: `Failed to copy URL: ${error}`,- })+ const fileUrl = formattedUrl.toString()++ // Also save it to cache+ const fileCache = {+ id: file.id,+ url: fileUrl,+ expiresIn: DEFAULT_EXPIRY,+ fetchedAt: Date.now(),}+ this.addFileToPreviewCache(fileCache)++ return fileUrl}}