Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Signature Frontend
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
GitLab 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
Electronic Signature Service
Signature Frontend
Commits
10633fc2
Unverified
Commit
10633fc2
authored
5 years ago
by
Bekerle, Patrizio
Browse files
Options
Downloads
Patches
Plain Diff
Prevent duplicate file names in ZIP file (VPU/Middleware/API#40)
parent
f1fce191
No related branches found
No related tags found
No related merge requests found
Pipeline
#9592
passed with warnings
5 years ago
Stage: test
Stage: deploy
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/utils.js
+11
-0
11 additions, 0 deletions
src/utils.js
src/vpu-signature-pdf-upload.js
+10
-3
10 additions, 3 deletions
src/vpu-signature-pdf-upload.js
with
21 additions
and
3 deletions
src/utils.js
+
11
−
0
View file @
10633fc2
...
...
@@ -44,3 +44,14 @@ export const getDataURIContentType = (dataURI) => {
return
dataURI
.
substring
(
5
,
base64Index
);
};
export
const
baseName
=
(
str
)
=>
{
let
base
=
String
(
str
).
substring
(
str
.
lastIndexOf
(
'
/
'
)
+
1
);
if
(
base
.
lastIndexOf
(
"
.
"
)
!==
-
1
)
{
base
=
base
.
substring
(
0
,
base
.
lastIndexOf
(
"
.
"
));
}
return
base
;
};
This diff is collapsed.
Click to expand it.
src/vpu-signature-pdf-upload.js
+
10
−
3
View file @
10633fc2
...
...
@@ -102,12 +102,19 @@ class SignaturePdfUpload extends VPUSignatureLitElement {
// see: https://stuk.github.io/jszip/
let
zip
=
new
JSZip
();
const
that
=
this
;
let
fileNames
=
[];
// add all signed pdf files
this
.
files
.
forEach
((
file
)
=>
{
console
.
log
(
file
);
// TODO: check for duplicate file names
zip
.
file
(
file
.
fileName
,
utils
.
getPDFFileBase64Content
(
file
),
{
base64
:
true
});
let
fileName
=
file
.
fileName
;
//
if
(
fileNames
.
indexOf
(
fileName
)
!==
-
1
)
{
fileName
=
utils
.
baseName
(
fileName
)
+
"
-
"
+
Math
.
random
().
toString
(
36
).
substring
(
7
)
+
"
.pdf
"
;
}
fileNames
.
push
(
fileName
);
zip
.
file
(
fileName
,
utils
.
getPDFFileBase64Content
(
file
),
{
base64
:
true
});
});
zip
.
generateAsync
({
type
:
"
blob
"
})
...
...
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