Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ARSnova Backend
Manage
Activity
Members
Labels
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Privacy
Imprint
Contact
Snippets
Groups
Projects
Show more breadcrumbs
Paul-Christian Volkmer
ARSnova Backend
Commits
dc8e8924
Commit
dc8e8924
authored
10 years ago
by
Daniel Vogel
Browse files
Options
Downloads
Patches
Plain Diff
Filesize check for pp logos
parent
b8a33faa
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/de/thm/arsnova/services/QuestionService.java
+1
-1
1 addition, 1 deletion
src/main/java/de/thm/arsnova/services/QuestionService.java
src/main/java/de/thm/arsnova/services/SessionService.java
+22
-5
22 additions, 5 deletions
src/main/java/de/thm/arsnova/services/SessionService.java
with
23 additions
and
6 deletions
src/main/java/de/thm/arsnova/services/QuestionService.java
+
1
−
1
View file @
dc8e8924
...
...
@@ -109,7 +109,7 @@ public class QuestionService implements IQuestionService, ApplicationEventPublis
question
.
setImage
(
base64ImageString
);
}
// base64 adds offset to filesize, formula
r
taken from: http://en.wikipedia.org/wiki/Base64#MIME
// base64 adds offset to filesize, formula taken from: http://en.wikipedia.org/wiki/Base64#MIME
final
int
fileSize
=
(
int
)
((
question
.
getImage
().
length
()-
814
)/
1.37
);
if
(
fileSize
>
uploadFileSizeByte
)
{
LOGGER
.
error
(
"Could not save file. File is too large with "
+
fileSize
+
" Byte."
);
...
...
This diff is collapsed.
Click to expand it.
src/main/java/de/thm/arsnova/services/SessionService.java
+
22
−
5
View file @
dc8e8924
...
...
@@ -28,9 +28,13 @@ import java.util.Map;
import
java.util.UUID
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.stereotype.Service
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
de.thm.arsnova.ImageUtils
;
import
de.thm.arsnova.connector.client.ConnectorClient
;
import
de.thm.arsnova.connector.model.Course
;
...
...
@@ -94,6 +98,11 @@ public class SessionService implements ISessionService {
@Autowired
(
required
=
false
)
private
ConnectorClient
connectorClient
;
@Value
(
"${pp.logofilesize_b}"
)
private
int
uploadFileSizeByte
;
public
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
SessionService
.
class
);
public
void
setDatabaseDao
(
final
IDatabaseDao
newDatabaseDao
)
{
databaseDao
=
newDatabaseDao
;
...
...
@@ -193,14 +202,22 @@ public class SessionService implements ISessionService {
throw
new
ForbiddenException
();
}
}
if
(
session
.
getPpLogo
()
!=
null
&&
session
.
getPpLogo
().
startsWith
(
"http"
))
{
final
String
base64ImageString
=
ImageUtils
.
encodeImageToString
(
session
.
getPpLogo
());
if
(
base64ImageString
==
null
)
{
if
(
session
.
getPpLogo
()
!=
null
)
{
if
(
session
.
getPpLogo
().
startsWith
(
"http"
))
{
final
String
base64ImageString
=
ImageUtils
.
encodeImageToString
(
session
.
getPpLogo
());
if
(
base64ImageString
==
null
)
{
throw
new
BadRequestException
();
}
session
.
setPpLogo
(
base64ImageString
);
}
// base64 adds offset to filesize, formula taken from: http://en.wikipedia.org/wiki/Base64#MIME
final
int
fileSize
=
(
int
)
((
session
.
getPpLogo
().
length
()-
814
)/
1.37
);
if
(
fileSize
>
uploadFileSizeByte
)
{
LOGGER
.
error
(
"Could not save file. File is too large with "
+
fileSize
+
" Byte."
);
throw
new
BadRequestException
();
}
session
.
setPpLogo
(
base64ImageString
);
}
return
databaseDao
.
saveSession
(
userService
.
getCurrentUser
(),
session
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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