1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
| const fileExtensions = { ".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", ".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document", ".pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation", ".xls": "application/vnd.ms-excel", ".doc": "application/msword", ".pdf": "application/pdf", ".txt": "text/plain", ".jpg": "image/jpeg", ".png": "image/png", ".gif": "image/gif", ".bmp": "image/bmp", ".webp": "image/webp", ".svg": "image/svg+xml", ".mp3": "audio/mpeg", ".wav": "audio/wav", ".ogg": "audio/ogg", ".mp4": "video/mp4", ".zip": "application/zip", ".rar": "application/x-rar-compressed", ".7z": "application/x-7z-compressed", ".tar": "application/x-tar", ".gz": "application/x-gzip", ".bz2": "application/x-bzip2", ".xz": "application/x-xz", ".lz": "application/x-lzip", ".lzma": "application/x-lzma", ".lzo": "application/x-lzop", ".lrz": "application/x-lrzip", ".lz4": "application/x-lz4", ".zst": "application/x-zstd", ".Z": "application/x-compress", ".lha": "application/x-lha", ".arj": "application/x-arj", ".cpio": "application/x-cpio", ".shar": "application/x-shar", ".iso": "application/x-iso9660-image", ".nrg": "application/x-nrg", ".img": "application/x-cd-image", ".mdf": "application/x-mdf", ".ima": "application/x-ima", ".timg": "application/x-timg", ".udf": "application/x-udf", ".cdl": "application/x-cdlink", ".cdi": "application/x-cdimage", ".cdinst": "application/x-cdinst", ".cdpack": "application/x-cdpack", ".cdproj": "application/x-cdproj", ".cdrecorder": "application/x-cdrecorder", ".cdrw": "application/x-cdrw", ".cdx": "application/x-cdx", };
const handleUploadZipChange=(event)=>{ let files = event.target.files; const zip=new JSZip(); zip.loadAsync(files[0], { arraybuffer: true }).then((zipItem)=>{ Object.values(zipItem.files).forEach((zipValue)=>{ const {dir,name}=zipValue; if(!dir){ const base = zipItem.file(name).async('arraybuffer') base.then((arrayBuffer)=>{ const fileName=name.split('/').pop(); const blobType=fileExtensions['.'+name.split('.').pop()]; console.log(blobType,'blobType') const blob = new Blob([arrayBuffer], { type: 'application/octet-stream' }); const file = new File([blob], fileName, { type: blobType||'application/octet-stream' }); Object.assign(file,{time:new Date().toLocaleString()}) fileList.value.push(file) }) } }) }) }
|