Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Toolkit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
digital blueprint
Web Component Framework
Toolkit
Commits
a33f30f2
Commit
a33f30f2
authored
4 years ago
by
Bekerle, Patrizio
Committed by
Reiter, Christoph
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Integrate mime type checking for files in a ZIP file (VPU/Apps/Signature#11)
parent
1b9d50e6
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
packages/file-handling/src/fileupload.js
+18
-12
18 additions, 12 deletions
packages/file-handling/src/fileupload.js
packages/file-handling/vendor/common
+1
-1
1 addition, 1 deletion
packages/file-handling/vendor/common
with
19 additions
and
13 deletions
packages/file-handling/src/fileupload.js
+
18
−
12
View file @
a33f30f2
import
{
i18n
}
from
'
./i18n
'
;
import
{
css
,
html
}
from
'
lit-element
'
;
import
{
ifDefined
}
from
'
lit-html/directives/if-defined
'
;
import
{
ScopedElementsMixin
}
from
'
@open-wc/scoped-elements
'
;
// import JSONLD from 'vpu-common/jsonld';
import
VPULitElement
from
'
vpu-common/vpu-lit-element
'
;
...
...
@@ -246,22 +245,29 @@ export class FileUpload extends ScopedElementsMixin(VPULitElement) {
if
(
zipEntry
.
dir
)
{
return
;
}
// TODO: find way to check mime type, see https://github.com/Stuk/jszip/issues/626
// if (!this.checkFileType(zipEntry)) {
// return;
// }
await
zipEntry
.
async
(
"
blob
"
)
.
then
((
blob
)
=>
{
filesToHandle
.
push
(
new
File
([
blob
],
zipEntry
.
name
));
},
(
e
)
=>
{
// handle the error
console
.
error
(
"
Decompressing of file in
"
+
file
.
name
+
"
failed:
"
+
e
.
message
);
});
.
then
(
async
(
blob
)
=>
{
// get mime type of Blob, see https://github.com/Stuk/jszip/issues/626
const
mimeType
=
await
commonUtils
.
getMimeTypeOfFile
(
blob
);
// create new file with name and mime type
const
zipEntryFile
=
new
File
([
blob
],
zipEntry
.
name
,
{
type
:
mimeType
});
// check mime type
if
(
!
this
.
checkFileType
(
zipEntryFile
))
{
return
;
}
filesToHandle
.
push
(
zipEntryFile
);
},
(
e
)
=>
{
// handle the error
console
.
error
(
"
Decompressing of file in
"
+
file
.
name
+
"
failed:
"
+
e
.
message
);
});
});
},
function
(
e
)
{
// handle the error
console
.
error
(
"
Loading of
"
+
file
.
name
+
"
failed:
"
+
e
.
message
);
console
.
error
(
"
Loading of
"
+
file
.
name
+
"
failed:
"
+
e
.
message
);
});
return
filesToHandle
;
...
...
This diff is collapsed.
Click to expand it.
common
@
338c8012
Subproject commit
821137e246fdcee9ccb04e4cfe420e7abec3186e
Subproject commit
338c8012f85e7b54a1e32f0f7af603e864573463
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment