ajout traitement d'un fichier unique
This commit is contained in:
		
							
								
								
									
										122
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										122
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							| @@ -13,6 +13,7 @@ | |||||||
|         "@nextcloud/files": "^3.10.0", |         "@nextcloud/files": "^3.10.0", | ||||||
|         "@nextcloud/initial-state": "^2.2.0", |         "@nextcloud/initial-state": "^2.2.0", | ||||||
|         "@nextcloud/vue": "^8.20.0", |         "@nextcloud/vue": "^8.20.0", | ||||||
|  |         "file-type": "^19.6.0", | ||||||
|         "i18next": "^24.0.2", |         "i18next": "^24.0.2", | ||||||
|         "jszip": "^3.10.1", |         "jszip": "^3.10.1", | ||||||
|         "vue": "^2.7.16", |         "vue": "^2.7.16", | ||||||
| @@ -1819,6 +1820,12 @@ | |||||||
|       "license": "MIT", |       "license": "MIT", | ||||||
|       "peer": true |       "peer": true | ||||||
|     }, |     }, | ||||||
|  |     "node_modules/@sec-ant/readable-stream": { | ||||||
|  |       "version": "0.4.1", | ||||||
|  |       "resolved": "https://registry.npmjs.org/@sec-ant/readable-stream/-/readable-stream-0.4.1.tgz", | ||||||
|  |       "integrity": "sha512-831qok9r2t8AlxLko40y2ebgSDhenenCatLVeW/uBtnHPyhHOvG0C7TvfgecV+wHzIm5KUICgzmVpWS+IMEAeg==", | ||||||
|  |       "license": "MIT" | ||||||
|  |     }, | ||||||
|     "node_modules/@shikijs/core": { |     "node_modules/@shikijs/core": { | ||||||
|       "version": "1.23.1", |       "version": "1.23.1", | ||||||
|       "resolved": "https://registry.npmjs.org/@shikijs/core/-/core-1.23.1.tgz", |       "resolved": "https://registry.npmjs.org/@shikijs/core/-/core-1.23.1.tgz", | ||||||
| @@ -1882,6 +1889,12 @@ | |||||||
|       "dev": true, |       "dev": true, | ||||||
|       "license": "MIT" |       "license": "MIT" | ||||||
|     }, |     }, | ||||||
|  |     "node_modules/@tokenizer/token": { | ||||||
|  |       "version": "0.3.0", | ||||||
|  |       "resolved": "https://registry.npmjs.org/@tokenizer/token/-/token-0.3.0.tgz", | ||||||
|  |       "integrity": "sha512-OvjF+z51L3ov0OyAU0duzsYuvO01PH7x4t6DJx+guahgTnBHkhJdG7soQeTSFLWN3efnHyibZ4Z8l2EuWwJN3A==", | ||||||
|  |       "license": "MIT" | ||||||
|  |     }, | ||||||
|     "node_modules/@types/body-parser": { |     "node_modules/@types/body-parser": { | ||||||
|       "version": "1.19.5", |       "version": "1.19.5", | ||||||
|       "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.5.tgz", |       "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.5.tgz", | ||||||
| @@ -6712,6 +6725,24 @@ | |||||||
|         "node": "^10.12.0 || >=12.0.0" |         "node": "^10.12.0 || >=12.0.0" | ||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|  |     "node_modules/file-type": { | ||||||
|  |       "version": "19.6.0", | ||||||
|  |       "resolved": "https://registry.npmjs.org/file-type/-/file-type-19.6.0.tgz", | ||||||
|  |       "integrity": "sha512-VZR5I7k5wkD0HgFnMsq5hOsSc710MJMu5Nc5QYsbe38NN5iPV/XTObYLc/cpttRTf6lX538+5uO1ZQRhYibiZQ==", | ||||||
|  |       "license": "MIT", | ||||||
|  |       "dependencies": { | ||||||
|  |         "get-stream": "^9.0.1", | ||||||
|  |         "strtok3": "^9.0.1", | ||||||
|  |         "token-types": "^6.0.0", | ||||||
|  |         "uint8array-extras": "^1.3.0" | ||||||
|  |       }, | ||||||
|  |       "engines": { | ||||||
|  |         "node": ">=18" | ||||||
|  |       }, | ||||||
|  |       "funding": { | ||||||
|  |         "url": "https://github.com/sindresorhus/file-type?sponsor=1" | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|     "node_modules/fill-range": { |     "node_modules/fill-range": { | ||||||
|       "version": "7.1.1", |       "version": "7.1.1", | ||||||
|       "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", |       "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", | ||||||
| @@ -7064,6 +7095,22 @@ | |||||||
|         "url": "https://github.com/sponsors/ljharb" |         "url": "https://github.com/sponsors/ljharb" | ||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|  |     "node_modules/get-stream": { | ||||||
|  |       "version": "9.0.1", | ||||||
|  |       "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-9.0.1.tgz", | ||||||
|  |       "integrity": "sha512-kVCxPF3vQM/N0B1PmoqVUqgHP+EeVjmZSQn+1oCRPxd2P21P2F19lIgbR3HBosbB1PUhOAoctJnfEn2GbN2eZA==", | ||||||
|  |       "license": "MIT", | ||||||
|  |       "dependencies": { | ||||||
|  |         "@sec-ant/readable-stream": "^0.4.1", | ||||||
|  |         "is-stream": "^4.0.1" | ||||||
|  |       }, | ||||||
|  |       "engines": { | ||||||
|  |         "node": ">=18" | ||||||
|  |       }, | ||||||
|  |       "funding": { | ||||||
|  |         "url": "https://github.com/sponsors/sindresorhus" | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|     "node_modules/get-symbol-description": { |     "node_modules/get-symbol-description": { | ||||||
|       "version": "1.0.2", |       "version": "1.0.2", | ||||||
|       "resolved": "https://registry.npmjs.org/get-symbol-description/-/get-symbol-description-1.0.2.tgz", |       "resolved": "https://registry.npmjs.org/get-symbol-description/-/get-symbol-description-1.0.2.tgz", | ||||||
| @@ -7852,7 +7899,6 @@ | |||||||
|       "version": "1.2.1", |       "version": "1.2.1", | ||||||
|       "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", |       "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", | ||||||
|       "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", |       "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", | ||||||
|       "dev": true, |  | ||||||
|       "funding": [ |       "funding": [ | ||||||
|         { |         { | ||||||
|           "type": "github", |           "type": "github", | ||||||
| @@ -7867,8 +7913,7 @@ | |||||||
|           "url": "https://feross.org/support" |           "url": "https://feross.org/support" | ||||||
|         } |         } | ||||||
|       ], |       ], | ||||||
|       "license": "BSD-3-Clause", |       "license": "BSD-3-Clause" | ||||||
|       "peer": true |  | ||||||
|     }, |     }, | ||||||
|     "node_modules/ignore": { |     "node_modules/ignore": { | ||||||
|       "version": "5.3.2", |       "version": "5.3.2", | ||||||
| @@ -8555,6 +8600,18 @@ | |||||||
|         "url": "https://github.com/sponsors/ljharb" |         "url": "https://github.com/sponsors/ljharb" | ||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|  |     "node_modules/is-stream": { | ||||||
|  |       "version": "4.0.1", | ||||||
|  |       "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-4.0.1.tgz", | ||||||
|  |       "integrity": "sha512-Dnz92NInDqYckGEUJv689RbRiTSEHCQ7wOVeALbkOz999YpqT46yMRIGtSNl2iCL1waAZSx40+h59NV/EwzV/A==", | ||||||
|  |       "license": "MIT", | ||||||
|  |       "engines": { | ||||||
|  |         "node": ">=18" | ||||||
|  |       }, | ||||||
|  |       "funding": { | ||||||
|  |         "url": "https://github.com/sponsors/sindresorhus" | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|     "node_modules/is-string": { |     "node_modules/is-string": { | ||||||
|       "version": "1.0.7", |       "version": "1.0.7", | ||||||
|       "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.0.7.tgz", |       "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.0.7.tgz", | ||||||
| @@ -11043,6 +11100,19 @@ | |||||||
|         "node": ">=0.12" |         "node": ">=0.12" | ||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|  |     "node_modules/peek-readable": { | ||||||
|  |       "version": "5.3.1", | ||||||
|  |       "resolved": "https://registry.npmjs.org/peek-readable/-/peek-readable-5.3.1.tgz", | ||||||
|  |       "integrity": "sha512-GVlENSDW6KHaXcd9zkZltB7tCLosKB/4Hg0fqBJkAoBgYG2Tn1xtMgXtSUuMU9AK/gCm/tTdT8mgAeF4YNeeqw==", | ||||||
|  |       "license": "MIT", | ||||||
|  |       "engines": { | ||||||
|  |         "node": ">=14.16" | ||||||
|  |       }, | ||||||
|  |       "funding": { | ||||||
|  |         "type": "github", | ||||||
|  |         "url": "https://github.com/sponsors/Borewit" | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|     "node_modules/picocolors": { |     "node_modules/picocolors": { | ||||||
|       "version": "1.1.1", |       "version": "1.1.1", | ||||||
|       "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", |       "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", | ||||||
| @@ -13518,6 +13588,23 @@ | |||||||
|       "integrity": "sha512-J8bbNyKKXl5qYcR36TIO8W3mVGVHrmmxsd5PAItGkmyzwJvybiw2IVq5nqd0i4LSNSkB/sx9VHllbfFdr9k1JA==", |       "integrity": "sha512-J8bbNyKKXl5qYcR36TIO8W3mVGVHrmmxsd5PAItGkmyzwJvybiw2IVq5nqd0i4LSNSkB/sx9VHllbfFdr9k1JA==", | ||||||
|       "license": "MIT" |       "license": "MIT" | ||||||
|     }, |     }, | ||||||
|  |     "node_modules/strtok3": { | ||||||
|  |       "version": "9.1.1", | ||||||
|  |       "resolved": "https://registry.npmjs.org/strtok3/-/strtok3-9.1.1.tgz", | ||||||
|  |       "integrity": "sha512-FhwotcEqjr241ZbjFzjlIYg6c5/L/s4yBGWSMvJ9UoExiSqL+FnFA/CaeZx17WGaZMS/4SOZp8wH18jSS4R4lw==", | ||||||
|  |       "license": "MIT", | ||||||
|  |       "dependencies": { | ||||||
|  |         "@tokenizer/token": "^0.3.0", | ||||||
|  |         "peek-readable": "^5.3.1" | ||||||
|  |       }, | ||||||
|  |       "engines": { | ||||||
|  |         "node": ">=16" | ||||||
|  |       }, | ||||||
|  |       "funding": { | ||||||
|  |         "type": "github", | ||||||
|  |         "url": "https://github.com/sponsors/Borewit" | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|     "node_modules/style-loader": { |     "node_modules/style-loader": { | ||||||
|       "version": "4.0.0", |       "version": "4.0.0", | ||||||
|       "resolved": "https://registry.npmjs.org/style-loader/-/style-loader-4.0.0.tgz", |       "resolved": "https://registry.npmjs.org/style-loader/-/style-loader-4.0.0.tgz", | ||||||
| @@ -14245,6 +14332,23 @@ | |||||||
|         "node": ">=0.6" |         "node": ">=0.6" | ||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|  |     "node_modules/token-types": { | ||||||
|  |       "version": "6.0.0", | ||||||
|  |       "resolved": "https://registry.npmjs.org/token-types/-/token-types-6.0.0.tgz", | ||||||
|  |       "integrity": "sha512-lbDrTLVsHhOMljPscd0yitpozq7Ga2M5Cvez5AjGg8GASBjtt6iERCAJ93yommPmz62fb45oFIXHEZ3u9bfJEA==", | ||||||
|  |       "license": "MIT", | ||||||
|  |       "dependencies": { | ||||||
|  |         "@tokenizer/token": "^0.3.0", | ||||||
|  |         "ieee754": "^1.2.1" | ||||||
|  |       }, | ||||||
|  |       "engines": { | ||||||
|  |         "node": ">=14.16" | ||||||
|  |       }, | ||||||
|  |       "funding": { | ||||||
|  |         "type": "github", | ||||||
|  |         "url": "https://github.com/sponsors/Borewit" | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|     "node_modules/tree-dump": { |     "node_modules/tree-dump": { | ||||||
|       "version": "1.0.2", |       "version": "1.0.2", | ||||||
|       "resolved": "https://registry.npmjs.org/tree-dump/-/tree-dump-1.0.2.tgz", |       "resolved": "https://registry.npmjs.org/tree-dump/-/tree-dump-1.0.2.tgz", | ||||||
| @@ -14587,6 +14691,18 @@ | |||||||
|       "license": "MIT", |       "license": "MIT", | ||||||
|       "peer": true |       "peer": true | ||||||
|     }, |     }, | ||||||
|  |     "node_modules/uint8array-extras": { | ||||||
|  |       "version": "1.4.0", | ||||||
|  |       "resolved": "https://registry.npmjs.org/uint8array-extras/-/uint8array-extras-1.4.0.tgz", | ||||||
|  |       "integrity": "sha512-ZPtzy0hu4cZjv3z5NW9gfKnNLjoz4y6uv4HlelAjDK7sY/xOkKZv9xK/WQpcsBB3jEybChz9DPC2U/+cusjJVQ==", | ||||||
|  |       "license": "MIT", | ||||||
|  |       "engines": { | ||||||
|  |         "node": ">=18" | ||||||
|  |       }, | ||||||
|  |       "funding": { | ||||||
|  |         "url": "https://github.com/sponsors/sindresorhus" | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|     "node_modules/unbox-primitive": { |     "node_modules/unbox-primitive": { | ||||||
|       "version": "1.0.2", |       "version": "1.0.2", | ||||||
|       "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz", |       "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz", | ||||||
|   | |||||||
| @@ -21,6 +21,7 @@ | |||||||
|     "@nextcloud/files": "^3.10.0", |     "@nextcloud/files": "^3.10.0", | ||||||
|     "@nextcloud/initial-state": "^2.2.0", |     "@nextcloud/initial-state": "^2.2.0", | ||||||
|     "@nextcloud/vue": "^8.20.0", |     "@nextcloud/vue": "^8.20.0", | ||||||
|  |     "file-type": "^19.6.0", | ||||||
|     "i18next": "^24.0.2", |     "i18next": "^24.0.2", | ||||||
|     "jszip": "^3.10.1", |     "jszip": "^3.10.1", | ||||||
|     "vue": "^2.7.16", |     "vue": "^2.7.16", | ||||||
|   | |||||||
| @@ -38,9 +38,8 @@ export default { | |||||||
| 		WebContentViewer   | 		WebContentViewer   | ||||||
| 	}, | 	}, | ||||||
| 	data() { | 	data() { | ||||||
| 		console.log('feur') |  | ||||||
| 		let zipUrl = document.getElementById('archiveInfos').getAttribute('dataarchiveurl'); | 		let zipUrl = document.getElementById('archiveInfos').getAttribute('dataarchiveurl'); | ||||||
| 		console.log(zipUrl) | 		//console.log(zipUrl) | ||||||
| 		return { | 		return { | ||||||
| 			zipUrl, | 			zipUrl, | ||||||
| 			sharedFile: null, | 			sharedFile: null, | ||||||
|   | |||||||
| @@ -407,7 +407,6 @@ export default { | |||||||
|                 try { |                 try { | ||||||
|                     this.isTransfering = true; |                     this.isTransfering = true; | ||||||
|                     const file = this.file; |                     const file = this.file; | ||||||
|                     console.log(file) |  | ||||||
|                     if (!file) return; |                     if (!file) return; | ||||||
|  |  | ||||||
|                     if (file.isList) { |                     if (file.isList) { | ||||||
|   | |||||||
| @@ -96,6 +96,7 @@ import ChevronRightIcon from 'vue-material-design-icons/ChevronRight.vue'; | |||||||
| import ChevronDownIcon from 'vue-material-design-icons/ChevronDown.vue'; | import ChevronDownIcon from 'vue-material-design-icons/ChevronDown.vue'; | ||||||
| import Loading from 'vue-material-design-icons/Loading.vue'; | import Loading from 'vue-material-design-icons/Loading.vue'; | ||||||
| import { ref } from 'vue'; | import { ref } from 'vue'; | ||||||
|  | import {fileTypeFromBuffer} from 'file-type'; | ||||||
|  |  | ||||||
| export default { | export default { | ||||||
|     name: 'WebContentViewer', |     name: 'WebContentViewer', | ||||||
| @@ -186,7 +187,12 @@ export default { | |||||||
|  |  | ||||||
|                 let response = await fetch(fullUrl); |                 let response = await fetch(fullUrl); | ||||||
|                 let responseJson = await response.json(); |                 let responseJson = await response.json(); | ||||||
|  |  | ||||||
|                 const zipData = responseJson.parameters.data; |                 const zipData = responseJson.parameters.data; | ||||||
|  |                 const first10Chars = zipData.substring(0,4); | ||||||
|  |  | ||||||
|  |                 // Check si le debut du fichier correspond a celui d'un zip | ||||||
|  |                 if(first10Chars === 'PK\x03\x04' || first10Chars === 'PK\x05\x06' || first10Chars === 'PK\x07\x08') { | ||||||
|                     this.zipName = this.zipUrl.split('/').pop(); |                     this.zipName = this.zipUrl.split('/').pop(); | ||||||
|                     const zip = await JSZip.loadAsync(zipData); |                     const zip = await JSZip.loadAsync(zipData); | ||||||
|                     this.zipSize = zipData.size; |                     this.zipSize = zipData.size; | ||||||
| @@ -247,6 +253,32 @@ export default { | |||||||
|  |  | ||||||
|                     initializeFolderMap(this.zipContent); |                     initializeFolderMap(this.zipContent); | ||||||
|                     console.log('Contenu du ZIP chargé avec succès'); |                     console.log('Contenu du ZIP chargé avec succès'); | ||||||
|  |                 } | ||||||
|  |                 else{ | ||||||
|  |                     const uint8Array = new Uint8Array(zipData.length); | ||||||
|  |                     for (let i = 0; i <zipData.length; i++) { | ||||||
|  |                         uint8Array[i] = zipData.charCodeAt(i); | ||||||
|  |                     } | ||||||
|  |  | ||||||
|  |                     try { | ||||||
|  |                         let type = await fileTypeFromBuffer(uint8Array);; | ||||||
|  |                         const file = new File([uint8Array], 'file.' + type.ext, {type: type.mime}); | ||||||
|  |                         let entry = [{ | ||||||
|  |                             name: file.name, | ||||||
|  |                             isDirectory: false, | ||||||
|  |                             size: file.size, | ||||||
|  |                             content: uint8Array,  // Initialiser 'content' pour les fichiers | ||||||
|  |                             children: null, | ||||||
|  |                             depth: 0, // Profondeur du fichier dans l'arborescence | ||||||
|  |                             //remove the name of the file from the path | ||||||
|  |                             parentPath: '', | ||||||
|  |                         }] | ||||||
|  |                         this.zipContent = entry; | ||||||
|  |                         console.log('Fichier chargé avec succès'); | ||||||
|  |                     } catch (e) { | ||||||
|  |                         console.log('Erreur lors du telechargement du fichier.'); | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|             } catch (error) { |             } catch (error) { | ||||||
|                 console.error('Erreur lors du chargement du contenu du ZIP :', error); |                 console.error('Erreur lors du chargement du contenu du ZIP :', error); | ||||||
|             } |             } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user