mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-19 00:41:41 +00:00
Javalin v5 bump (#930)
This commit is contained in:
@@ -69,7 +69,7 @@ public class RequestHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!file.getExtension().contains("zip")) {
|
||||
if (!file.extension().contains("zip")) {
|
||||
ctx.status(400);
|
||||
ctx.result(
|
||||
"The uploaded file was not of type 'zip'. The uploaded file should be a .zip file.");
|
||||
@@ -132,7 +132,7 @@ public class RequestHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!file.getExtension().contains("json")) {
|
||||
if (!file.extension().contains("json")) {
|
||||
ctx.status(400);
|
||||
ctx.result(
|
||||
"The uploaded file was not of type 'json'. The uploaded file should be a .json file.");
|
||||
@@ -174,7 +174,7 @@ public class RequestHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!file.getExtension().contains("json")) {
|
||||
if (!file.extension().contains("json")) {
|
||||
ctx.status(400);
|
||||
ctx.result(
|
||||
"The uploaded file was not of type 'json'. The uploaded file should be a .json file.");
|
||||
@@ -216,7 +216,7 @@ public class RequestHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!file.getExtension().contains("json")) {
|
||||
if (!file.extension().contains("json")) {
|
||||
ctx.status(400);
|
||||
ctx.result(
|
||||
"The uploaded file was not of type 'json'. The uploaded file should be a .json file.");
|
||||
@@ -258,7 +258,7 @@ public class RequestHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!file.getExtension().contains("jar")) {
|
||||
if (!file.extension().contains("jar")) {
|
||||
ctx.status(400);
|
||||
ctx.result(
|
||||
"The uploaded file was not of type 'jar'. The uploaded file should be a .jar file.");
|
||||
@@ -273,7 +273,7 @@ public class RequestHandler {
|
||||
File targetFile = new File(filePath.toString());
|
||||
var stream = new FileOutputStream(targetFile);
|
||||
|
||||
file.getContent().transferTo(stream);
|
||||
file.content().transferTo(stream);
|
||||
stream.close();
|
||||
|
||||
ctx.status(200);
|
||||
@@ -492,14 +492,20 @@ public class RequestHandler {
|
||||
*/
|
||||
private static Optional<File> handleTempFileCreation(UploadedFile file) {
|
||||
var tempFilePath =
|
||||
new File(Path.of(System.getProperty("java.io.tmpdir"), file.getFilename()).toString());
|
||||
tempFilePath.getParentFile().mkdirs();
|
||||
new File(Path.of(System.getProperty("java.io.tmpdir"), file.filename()).toString());
|
||||
boolean makeDirsRes = tempFilePath.getParentFile().mkdirs();
|
||||
|
||||
if (!makeDirsRes) {
|
||||
logger.error(
|
||||
"There was an error while uploading " + file.filename() + " to the temp folder!");
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
try {
|
||||
FileUtils.copyInputStreamToFile(file.getContent(), tempFilePath);
|
||||
FileUtils.copyInputStreamToFile(file.content(), tempFilePath);
|
||||
} catch (IOException e) {
|
||||
logger.error(
|
||||
"There was an error while uploading " + file.getFilename() + " to the temp folder!");
|
||||
"There was an error while uploading " + file.filename() + " to the temp folder!");
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user