diff --git a/packages/web-app-files/src/components/AppBar/CreateAndUpload.vue b/packages/web-app-files/src/components/AppBar/CreateAndUpload.vue index 794ad4992d4..ba8f6186792 100644 --- a/packages/web-app-files/src/components/AppBar/CreateAndUpload.vue +++ b/packages/web-app-files/src/components/AppBar/CreateAndUpload.vue @@ -281,6 +281,8 @@ export default defineComponent({ resource = buildResource(resource) + this.$uppyService.$emit('uploadedFileFetched', file, resource) + // Update table only if the file was uploaded to the current directory if (fileIsInCurrentPath) { this.UPSERT_RESOURCE(resource) diff --git a/packages/web-app-files/src/views/FilesDrop.vue b/packages/web-app-files/src/views/FilesDrop.vue index b47abc8fbf4..1b1071ac866 100644 --- a/packages/web-app-files/src/views/FilesDrop.vue +++ b/packages/web-app-files/src/views/FilesDrop.vue @@ -57,6 +57,7 @@ export default { onMounted(() => { uppyService.$on('filesSelected', instance.onFilesSelected) + uppyService.$on('uploadSuccess', instance.onFileSuccess) uppyService.$on('uploadError', instance.onFileError) uppyService.useDropTarget({ @@ -67,6 +68,7 @@ export default { onUnmounted(() => { uppyService.$off('filesSelected', instance.onFilesSelected) + uppyService.$off('uploadSuccess', instance.onFileSuccess) uppyService.$off('uploadError', instance.onFileError) }) @@ -165,6 +167,10 @@ export default { this.$uppyService.uploadFiles(uppyResources) }, + onFileSuccess(uppyResource) { + this.$uppyService.$emit('uploadedFileFetched', uppyResource, { name: uppyResource.name }) + }, + onFileError(error) { console.error(error) this.showMessage({ diff --git a/packages/web-runtime/src/components/UploadInfo.vue b/packages/web-runtime/src/components/UploadInfo.vue index 8c2894fcb09..dc16895a32d 100644 --- a/packages/web-runtime/src/components/UploadInfo.vue +++ b/packages/web-runtime/src/components/UploadInfo.vue @@ -120,19 +120,10 @@ export default { this.filesUploading = 0 this.uploadCancelled = true }) - this.$uppyService.$on('uploadSuccess', (file) => { - // @TODO we need the storage ID here... maybe fetch the file via DAV and call buildResources()? - - let path = file.meta.currentFolder - if (file.meta.relativePath) { - path += file.meta.relativePath - } - path += file.name - + this.$uppyService.$on('uploadedFileFetched', (uppyResource, fetchedFile) => { this.successfulUploads.push({ - ...file, - path, - targetRoute: file.meta.route + ...fetchedFile, + targetRoute: uppyResource.meta.route }) }) }, @@ -169,7 +160,8 @@ export default { name: targetRoute.name, query: targetRoute.query, params: { - ...(storageId && path && { storageId }) + ...(storageId && path && { storageId }), + storage: targetRoute.params?.storage } }