下载文件转换
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
dde53103f9
commit
2ed051e25b
|
@ -328,6 +328,7 @@ export default {
|
|||
}/${this.$fd('IsDicom', true)}/${study.StudyCode
|
||||
}/IMAGE/${fileName}`,
|
||||
url: this.OSSclientConfig.basePath + instance.Path,
|
||||
IsEncapsulated: instance.IsEncapsulated
|
||||
}
|
||||
if (this.IsReadingTaskViewInOrder === 0) {
|
||||
obj = {
|
||||
|
@ -336,6 +337,7 @@ export default {
|
|||
true
|
||||
)}/IMAGE/${fileName}`,
|
||||
url: this.OSSclientConfig.basePath + instance.Path,
|
||||
IsEncapsulated: instance.IsEncapsulated
|
||||
}
|
||||
}
|
||||
files.push(obj)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import streamSaver from "streamsaver";
|
||||
import "streamsaver/examples/zip-stream.js";
|
||||
import store from '@/store'
|
||||
import dcmjs from './dcmUpload/dcmjs'
|
||||
streamSaver.mitm = `${window.location.origin}/mitm.html?version=2.0.0`
|
||||
// 下载文件并压缩
|
||||
function zipFiles(zipName, files) {
|
||||
|
@ -19,7 +20,10 @@ function zipFiles(zipName, files) {
|
|||
if (fileInfo.done) {//迭代终止
|
||||
ctrl.close();
|
||||
} else {
|
||||
let { name, url } = fileInfo.value;
|
||||
let { name, url, IsEncapsulated = false } = fileInfo.value;
|
||||
if (IsEncapsulated) {
|
||||
url = await downloadFileToUrl(url)
|
||||
}
|
||||
// url = decodeUtf8(url); // 待定,可能做过特殊处理
|
||||
return fetch(url).then(res => {
|
||||
ctrl.enqueue({
|
||||
|
@ -99,6 +103,24 @@ function decodeUtf8(bytes) {
|
|||
str2.pop();
|
||||
return str2.join("/") + '/' + name;
|
||||
}
|
||||
// 下载文件进行修改并输出本地url
|
||||
function downloadFileToUrl(url) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', url);
|
||||
xhr.responseType = 'arraybuffer';
|
||||
xhr.onload = function () {
|
||||
const arraybuffer = xhr.response;
|
||||
let dataset = dcmjs.data.DicomMessage.readFile(arraybuffer)
|
||||
let newDicomFile = dataset.write({ fragmentMultiframe: false }) // fragmentMultiframe 原始数据是否进行分割
|
||||
const bufferArray = new Uint8Array(newDicomFile)
|
||||
const blob = new Blob([bufferArray], { type: 'application/octet-stream' })
|
||||
const href = URL.createObjectURL(blob)
|
||||
resolve(href)
|
||||
};
|
||||
xhr.send();
|
||||
})
|
||||
}
|
||||
export async function downLoadFile(file, name, type = 'file') {
|
||||
if (type === 'zip') return await zipFiles(name, file);
|
||||
return await updateFile(file, name)
|
||||
|
|
|
@ -1201,6 +1201,7 @@ export default {
|
|||
true
|
||||
)}/${study.StudyCode}_${study.StudyTime.split(' ')[0]}/IMAGE/${fileName}`,
|
||||
url: this.OSSclientConfig.basePath + instance.Path,
|
||||
IsEncapsulated: instance.IsEncapsulated
|
||||
}
|
||||
files.push(obj)
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue