add download for binary files

This commit is contained in:
Salem Yaslem 2024-11-04 14:18:19 +03:00
parent 249cc552ec
commit 8b1b7d7aa2
4 changed files with 25 additions and 3 deletions

View File

@ -147,15 +147,15 @@ function stepUp(path: string) {
</template> </template>
<template <template
v-if="!filesManager.getFile(selectedPath)?.isFolder && imageExtensions.includes(filesManager.getFile(selectedPath)?.extension)"> v-if="!filesManager.getFile(selectedPath)?.isFolder && imageExtensions.includes(filesManager.getFile(selectedPath)?.extension)">
<ImageViewer :src="mediaBlobUrl"></ImageViewer> <MediaImageViewer :src="mediaBlobUrl"></MediaImageViewer>
</template> </template>
<template <template
v-if="!filesManager.getFile(selectedPath)?.isFolder && files.length && !imageExtensions.includes(filesManager.getFile(selectedPath)?.extension) && !videoExtensions.includes(filesManager.getFile(selectedPath)?.extension) && !binaryExtensions.includes(filesManager.getFile(selectedPath)?.extension)"> v-if="!filesManager.getFile(selectedPath)?.isFolder && files.length && !imageExtensions.includes(filesManager.getFile(selectedPath)?.extension) && !videoExtensions.includes(filesManager.getFile(selectedPath)?.extension) && !binaryExtensions.includes(filesManager.getFile(selectedPath)?.extension)">
<TextEditor :file="filesManager.getFile(selectedPath)" :filesManager="filesManager"></TextEditor> <MediaTextEditor :file="filesManager.getFile(selectedPath)" :filesManager="filesManager"></MediaTextEditor>
</template> </template>
<template <template
v-if="!filesManager.getFile(selectedPath)?.isFolder && files.length && binaryExtensions.includes(filesManager.getFile(selectedPath)?.extension)"> v-if="!filesManager.getFile(selectedPath)?.isFolder && files.length && binaryExtensions.includes(filesManager.getFile(selectedPath)?.extension)">
<BinaryViewer :file="filesManager.getFile(selectedPath)" :filesManager="filesManager"></BinaryViewer> <MediaBinaryViewer :file="filesManager.getFile(selectedPath)" :filesManager="filesManager"></MediaBinaryViewer>
</template> </template>
<template v-if="!files.length"> <template v-if="!files.length">
<!-- tutorial drag and drop zipped file here and review it securely --> <!-- tutorial drag and drop zipped file here and review it securely -->

View File

@ -2,6 +2,7 @@
import { ref, onMounted, computed } from 'vue' import { ref, onMounted, computed } from 'vue'
import { FilesManager } from '~/composables/files-manager'; import { FilesManager } from '~/composables/files-manager';
import { iFile } from '~/composables/worker/7zip-manager'; import { iFile } from '~/composables/worker/7zip-manager';
import { VBtn } from 'vuetify/components';
interface Props { interface Props {
file: iFile, file: iFile,
@ -54,6 +55,10 @@ function updateVisibleRows() {
} }
} }
function downloadBinaryFile() {
filesManager.downloadFile(file.path);
}
onMounted(async () => { onMounted(async () => {
try { try {
buffer.value = await filesManager.getFileContent(file.path, "binary") as Uint8Array buffer.value = await filesManager.getFileContent(file.path, "binary") as Uint8Array
@ -67,6 +72,17 @@ onMounted(async () => {
<template> <template>
<div class="binary-viewer"> <div class="binary-viewer">
<div class="toolbar">
<v-btn
color="primary"
variant="flat"
prepend-icon="mdi-download"
@click="downloadBinaryFile"
size="small"
>
Download {{ file.name }}
</v-btn>
</div>
<div v-if="isLoading" class="loading"> <div v-if="isLoading" class="loading">
Loading... Loading...
</div> </div>
@ -141,4 +157,10 @@ onMounted(async () => {
align-items: center; align-items: center;
height: 100%; height: 100%;
} }
.toolbar {
margin-bottom: 1rem;
display: flex;
justify-content: flex-end;
}
</style> </style>