Skip to content

Commit afc4038

Browse files
authored
Merge pull request #216 from iceljc/features/refine-chat-window
handle file download
2 parents 86f0b73 + d4c4926 commit afc4038

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/routes/page/knowledge-base/documents/knowledge-document-upload.svelte

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
uploadKnowledgeDocuments,
1919
deleteKnowledgeDocument
2020
} from '$lib/services/knowledge-base-service';
21+
import { isHtml } from '$lib/helpers/utils/file';
2122
2223
const svelteDispatch = createEventDispatcher();
2324
@@ -261,10 +262,18 @@
261262
const found = savedFiles.find((_, idx) => idx === index);
262263
if (!found) return;
263264
264-
const url = isExternalUrl(found.file_url) ?
265-
found.file_url : `${PUBLIC_SERVICE_URL}${found.file_url}?access_token=${$userStore?.token}`;
266-
267-
window.open(url);
265+
let url = '';
266+
if (!isHtml(found.file_extension || found.file_name)) {
267+
if (found.file_url) {
268+
url = isExternalUrl(found.file_url) ? found.file_url : `${PUBLIC_SERVICE_URL}${found.file_url}?access_token=${$userStore?.token}`;
269+
}
270+
} else {
271+
url = found.ref_data?.url;
272+
}
273+
274+
if (url) {
275+
window.open(url);
276+
}
268277
}
269278
270279
function reset() {

0 commit comments

Comments
 (0)