-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy patharchiveLoader.js
More file actions
31 lines (23 loc) · 790 Bytes
/
Copy patharchiveLoader.js
File metadata and controls
31 lines (23 loc) · 790 Bytes
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
import JSZip from 'jszip';
const zip = new JSZip();
function archiveLoader (selectedFile) {
return new Promise(function (resolve, reject) {
const str = selectedFile.name.substring(selectedFile.name.length - 4);
if (str === '.zip') {
zip.loadAsync(selectedFile).then(function () {
returnObject(zip);
resolve('success');
}).catch(function (err) {
console.log(`Unzipping Error: ${err}`);
reject(`Unzipping Error: ${err}`);
}); // end catch
} else {
console.log('This is not a zip file');
reject('This is not a zip file');
} // end if else
}); // end promise
} // end function archiveLoader
function returnObject () {
return zip;
} // end function returnObject
export { returnObject, archiveLoader };