allow -1 for the paste limit to disable it
This commit is contained in:
parent
5a0286412f
commit
2ca9b6ce5f
@ -44,10 +44,13 @@ public class PasteService {
|
|||||||
*/
|
*/
|
||||||
public String createPaste(String content) {
|
public String createPaste(String content) {
|
||||||
int length = content.length();
|
int length = content.length();
|
||||||
if (length > uploadSizeLimit) {
|
|
||||||
|
// Check if the content is too large.
|
||||||
|
if (length > uploadSizeLimit && uploadSizeLimit != -1) {
|
||||||
throw new BadRequestException("The paste content is too large, the limit is " + uploadSizeLimit + " characters");
|
throw new BadRequestException("The paste content is too large, the limit is " + uploadSizeLimit + " characters");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Save the paste to the database.
|
||||||
return pasteRepository.save(new Paste(
|
return pasteRepository.save(new Paste(
|
||||||
RandomStringUtils.randomAlphabetic(idLength),
|
RandomStringUtils.randomAlphabetic(idLength),
|
||||||
System.currentTimeMillis(),
|
System.currentTimeMillis(),
|
||||||
@ -66,7 +69,7 @@ public class PasteService {
|
|||||||
|
|
||||||
// The paste does not exist.
|
// The paste does not exist.
|
||||||
if (paste.isEmpty()) {
|
if (paste.isEmpty()) {
|
||||||
throw new ResourceNotFoundException("Paste with id '%s' not found".formatted(id));
|
throw new ResourceNotFoundException("Paste '%s' not found".formatted(id));
|
||||||
}
|
}
|
||||||
return paste.get();
|
return paste.get();
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ spring:
|
|||||||
paste:
|
paste:
|
||||||
# The length of the ID for the paste
|
# The length of the ID for the paste
|
||||||
id-length: 12
|
id-length: 12
|
||||||
# The limit of the paste size (in characters)
|
# The limit of the paste size (in characters) - You can set it to "-1" to disable the limit
|
||||||
upload-size-limit: 400000
|
upload-size-limit: 400000
|
||||||
|
|
||||||
# Set the embedded MongoDB version
|
# Set the embedded MongoDB version
|
||||||
|
Reference in New Issue
Block a user