Compare commits

..

No commits in common. "741c723bab65d14b6632f0b86e92646c9655442a" and "5a943fbefe0bd68a0b1126fe8a4248c1b87c0e2c" have entirely different histories.

1 changed files with 25 additions and 37 deletions

View File

@ -60,11 +60,7 @@ async function ossGenerateSTS() {
let params = Object.assign({path: objectName}, fileInfo) let params = Object.assign({path: objectName}, fileInfo)
addOrUpdateFileUploadRecord(params) addOrUpdateFileUploadRecord(params)
} else if (trialId) { } else if (trialId) {
const fileName = objectName.split('/').pop() let params = { trialId, path: objectName }
const fileType = fileName.includes('.')
? fileName.split('.').pop().toLowerCase()
: ''
let params = { trialId, path: objectName, fileName, fileType }
addOrUpdateFileUploadRecord(params) addOrUpdateFileUploadRecord(params)
} }
resolve({ resolve({
@ -117,11 +113,7 @@ async function ossGenerateSTS() {
let params = Object.assign({path: data.path}, fileInfo) let params = Object.assign({path: data.path}, fileInfo)
addOrUpdateFileUploadRecord(params) addOrUpdateFileUploadRecord(params)
} else if (trialId) { } else if (trialId) {
const fileName = data.path.split('/').pop() let params = { trialId, path: data.path }
const fileType = fileName.includes('.')
? fileName.split('.').pop().toLowerCase()
: ''
let params = { trialId, path: data.path, fileName, fileType }
addOrUpdateFileUploadRecord(params) addOrUpdateFileUploadRecord(params)
} }
@ -249,11 +241,7 @@ function uploadAWS(aws, data, progress, fileInfo) {
let params = Object.assign({path: decodeUtf8(curPath)}, fileInfo) let params = Object.assign({path: decodeUtf8(curPath)}, fileInfo)
addOrUpdateFileUploadRecord(params) addOrUpdateFileUploadRecord(params)
} else if (trialId) { } else if (trialId) {
const fileName = decodeUtf8(curPath).split('/').pop() let params = { trialId, path: decodeUtf8(curPath) }
const fileType = fileName.includes('.')
? fileName.split('.').pop().toLowerCase()
: ''
let params = { trialId, path: decodeUtf8(curPath), fileName, fileType }
addOrUpdateFileUploadRecord(params) addOrUpdateFileUploadRecord(params)
} }
resolve({ resolve({
@ -368,33 +356,33 @@ function isCredentialsExpired(credentials) {
function mimeTypeToExt(mimeType) { function mimeTypeToExt(mimeType) {
const map = { const map = {
// 图片 // 图片
'image/jpeg': 'jpg', 'image/jpeg': '.jpg',
'image/jpg': 'jpg', 'image/jpg': '.jpg',
'image/png': 'png', 'image/png': '.png',
'image/gif': 'gif', 'image/gif': '.gif',
'image/webp': 'webp', 'image/webp': '.webp',
'image/svg+xml': 'svg', 'image/svg+xml': '.svg',
'image/bmp': 'bmp', 'image/bmp': '.bmp',
// 文档 // 文档
'application/dicom': 'dcm', 'application/dicom': '.dcm',
'application/pdf': 'pdf', 'application/pdf': '.pdf',
'application/msword': 'doc', 'application/msword': '.doc',
'application/vnd.openxmlformats-officedocument.wordprocessingml.document': 'docx', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': '.docx',
'application/vnd.ms-excel': 'xls', 'application/vnd.ms-excel': '.xls',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': 'xlsx', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': '.xlsx',
'application/vnd.ms-powerpoint': '.ppt', 'application/vnd.ms-powerpoint': '.ppt',
'application/vnd.openxmlformats-officedocument.presentationml.presentation': 'pptx', 'application/vnd.openxmlformats-officedocument.presentationml.presentation': '.pptx',
'text/plain': 'txt', 'text/plain': '.txt',
// 音频/视频 // 音频/视频
'audio/mpeg': 'mp3', 'audio/mpeg': '.mp3',
'audio/wav': 'wav', 'audio/wav': '.wav',
'video/mp4': 'mp4', 'video/mp4': '.mp4',
'video/mpeg': 'mpeg', 'video/mpeg': '.mpeg',
// 压缩包 // 压缩包
'application/zip': 'zip', 'application/zip': '.zip',
'application/x-rar-compressed': 'rar', 'application/x-rar-compressed': '.rar',
'application/x-7z-compressed': '7z', 'application/x-7z-compressed': '.7z',
}; };
return map[mimeType] || ''; // 找不到返回空字符串 return map[mimeType] || ''; // 找不到返回空字符串
} }