+
@@ -87,45 +99,51 @@ async function downloadFile(item: Record
) {
-
diff --git a/packages/nc-gui-v2/components/cell/attachment/index.vue b/packages/nc-gui-v2/components/cell/attachment/index.vue
index 594558f815..408fd96331 100644
--- a/packages/nc-gui-v2/components/cell/attachment/index.vue
+++ b/packages/nc-gui-v2/components/cell/attachment/index.vue
@@ -23,7 +23,7 @@ const emits = defineEmits()
const dropZoneRef = ref()
-const { modalVisible, attachments, visibleItems, onFileSelect, isLoading, open, FileIcon, fileRemovedHook, fileAddedHook } =
+const { modalVisible, attachments, visibleItems, onDrop, isLoading, open, FileIcon, fileRemovedHook, fileAddedHook } =
useProvideAttachmentCell()
const { isOverDropZone } = useDropZone(dropZoneRef, onDrop)
@@ -46,13 +46,6 @@ fileAddedHook.on((data) => {
emits('update:modelValue', data)
})
-function onDrop(droppedFiles: File[] | null) {
- if (droppedFiles) {
- // set files
- onFileSelect(droppedFiles)
- }
-}
-
const selectImage = (file: any, i: unknown) => {
// todo: implement
}
diff --git a/packages/nc-gui-v2/components/cell/attachment/utils.ts b/packages/nc-gui-v2/components/cell/attachment/utils.ts
index c98b0a53d0..5f19130b7f 100644
--- a/packages/nc-gui-v2/components/cell/attachment/utils.ts
+++ b/packages/nc-gui-v2/components/cell/attachment/utils.ts
@@ -1,4 +1,5 @@
import { notification } from 'ant-design-vue'
+import FileSaver from 'file-saver'
import { computed, createEventHook, inject, ref, useApi, useFileDialog, useInjectionState, useProject, watch } from '#imports'
import { ColumnInj, EditModeInj, MetaInj } from '~/context'
import { isImage } from '~/utils'
@@ -93,6 +94,17 @@ export const [useProvideAttachmentCell, useAttachmentCell] = useInjectionState((
fileAddedHook.trigger([...attachments.value, ...newAttachments])
}
+ function onDrop(droppedFiles: File[] | null) {
+ if (droppedFiles) {
+ // set files
+ onFileSelect(droppedFiles)
+ }
+ }
+
+ async function downloadFile(item: Record) {
+ FileSaver.saveAs(item.url || item.data, item.title)
+ }
+
const FileIcon = (icon: string) => {
switch (icon) {
case 'mdi-pdf-box':
@@ -125,11 +137,12 @@ export const [useProvideAttachmentCell, useAttachmentCell] = useInjectionState((
isLoading,
api,
open,
- onFileSelect,
+ onDrop,
modalVisible,
FileIcon,
fileRemovedHook,
fileAddedHook,
removeFile,
+ downloadFile,
}
}, 'attachmentCell')