diff --git a/packages/nc-gui/components/cell/attachment/utils.ts b/packages/nc-gui/components/cell/attachment/utils.ts
index 6b202c519c..438ae5c599 100644
--- a/packages/nc-gui/components/cell/attachment/utils.ts
+++ b/packages/nc-gui/components/cell/attachment/utils.ts
@@ -14,6 +14,7 @@ import {
message,
ref,
useApi,
+ useAttachment,
useFileDialog,
useI18n,
useInjectionState,
@@ -60,6 +61,8 @@ export const [useProvideAttachmentCell, useAttachmentCell] = useInjectionState(
const { t } = useI18n()
+ const { getAttachmentSrc } = useAttachment()
+
const defaultAttachmentMeta = {
...(appInfo.value.ee && {
// Maximum Number of Attachments per cell
@@ -226,31 +229,12 @@ export const [useProvideAttachmentCell, useAttachmentCell] = useInjectionState(
/** download a file */
async function downloadFile(item: AttachmentType) {
- ;(await import('file-saver')).saveAs(item.url || item.data, item.title)
- }
-
- /** construct the attachment url
- * See /packages/nocodb/src/lib/version-upgrader/ncAttachmentUpgrader.ts for the details
- * */
- async function getAttachmentUrl(item: AttachmentType) {
- const path = item?.path
- // if path doesn't exist, use `item.url`
- if (path) {
- // try ${appInfo.value.ncSiteUrl}/${item.path} first
- const url = `${appInfo.value.ncSiteUrl}/${item.path}`
- try {
- const res = await fetch(url)
- if (res.ok) {
- // use `url` if it is accessible
- return Promise.resolve(url)
- }
- } catch {
- // for some cases, `url` is not accessible as expected
- // do nothing here
- }
+ const src = await getAttachmentSrc(item)
+ if (src) {
+ ;(await import('file-saver')).saveAs(src, item.title)
+ } else {
+ message.error('Failed to download file')
}
- // if it fails, use the original url
- return Promise.resolve(item.url)
}
const FileIcon = (icon: string) => {
@@ -294,7 +278,6 @@ export const [useProvideAttachmentCell, useAttachmentCell] = useInjectionState(
storedFiles,
bulkDownloadFiles,
defaultAttachmentMeta,
- getAttachmentUrl,
}
},
'useAttachmentCell',
diff --git a/packages/nc-gui/components/dashboard/TreeView.vue b/packages/nc-gui/components/dashboard/TreeView.vue
index 3f0e23100b..2c028ad472 100644
--- a/packages/nc-gui/components/dashboard/TreeView.vue
+++ b/packages/nc-gui/components/dashboard/TreeView.vue
@@ -35,7 +35,7 @@ const { addTab, updateTab } = useTabs()
const { $api, $e } = useNuxtApp()
-const { project, loadProject, bases, tables, loadTables, isSharedBase } = useProject()
+const { bases, tables, loadTables, isSharedBase } = useProject()
const { activeTab } = useTabs()
@@ -324,12 +324,6 @@ const setIcon = async (icon: string, table: TableType) => {
message.error(await extractSdkResponseErrorMsg(e))
}
}
-
-onMounted(async () => {
- if (!project.value?.id) {
- await loadProject()
- }
-})
diff --git a/packages/nc-gui/components/smartsheet/Gallery.vue b/packages/nc-gui/components/smartsheet/Gallery.vue
index 0128997248..2ca93ab3f8 100644
--- a/packages/nc-gui/components/smartsheet/Gallery.vue
+++ b/packages/nc-gui/components/smartsheet/Gallery.vue
@@ -18,11 +18,13 @@ import {
createEventHook,
extractPkFromRow,
inject,
+ isImage,
isLTAR,
nextTick,
onMounted,
provide,
ref,
+ useAttachment,
useViewData,
} from '#imports'
import type { Row as RowType } from '~/lib'
@@ -64,6 +66,8 @@ const route = useRoute()
const router = useRouter()
+const { getPossibleAttachmentSrc } = useAttachment()
+
const fieldsWithoutCover = computed(() => fields.value.filter((f) => f.id !== galleryData.value?.fk_cover_image_col_id))
const coverImageColumn: any = $(
@@ -199,14 +203,14 @@ watch(view, async (nextView) => {
-
+
+
+
diff --git a/packages/nc-gui/components/smartsheet/Grid.vue b/packages/nc-gui/components/smartsheet/Grid.vue
index 9ae398dc51..d33ffa5507 100644
--- a/packages/nc-gui/components/smartsheet/Grid.vue
+++ b/packages/nc-gui/components/smartsheet/Grid.vue
@@ -714,9 +714,9 @@ const closeAddColumnDropdown = () => {
@contextmenu="showContextMenu"
>
-