mirror of
https://github.com/filecoin-project/slate.git
synced 2024-12-25 01:52:45 +03:00
fixes JSZip throw when checking if a file is a zip
This commit is contained in:
parent
7306b3bd8b
commit
de50a08a2c
@ -79,7 +79,6 @@ export const upload = async ({ file, context, bucketName, routes }) => {
|
||||
});
|
||||
|
||||
XHR.open("post", path, true);
|
||||
|
||||
XHR.setRequestHeader("authorization", getCookie(Credentials.session.key));
|
||||
XHR.onerror = (event) => {
|
||||
console.log(event);
|
||||
|
@ -148,13 +148,17 @@ export const isPreviewableImage = (type = "") => {
|
||||
};
|
||||
|
||||
export const isUnityFile = async (file) => {
|
||||
const zip = new JSZip();
|
||||
try {
|
||||
const zip = new JSZip();
|
||||
|
||||
const contents = await zip.loadAsync(file);
|
||||
const fileNames = Object.keys(contents.files);
|
||||
const contents = await zip.loadAsync(file);
|
||||
const fileNames = Object.keys(contents.files);
|
||||
|
||||
// NOTE(daniel): every Unity game file will have this file
|
||||
const unityRegex = new RegExp(/unityloader.js/i);
|
||||
// NOTE(daniel): every Unity game file will have this file
|
||||
const unityRegex = new RegExp(/unityloader.js/i);
|
||||
|
||||
return fileNames.some((file) => unityRegex.test(file));
|
||||
return fileNames.some((file) => unityRegex.test(file));
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user