aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/http
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/juick/http')
-rw-r--r--src/main/java/com/juick/http/www/Utils.java18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/main/java/com/juick/http/www/Utils.java b/src/main/java/com/juick/http/www/Utils.java
index e6fcad729..21577a405 100644
--- a/src/main/java/com/juick/http/www/Utils.java
+++ b/src/main/java/com/juick/http/www/Utils.java
@@ -60,15 +60,17 @@ public class Utils {
Part filePart = request.getPart("attach");
if (filePart != null) {
String partname = Utils.getPartFilename(filePart);
- String attachmentType = partname.substring(partname.length() - 3).toLowerCase();
- if (attachmentType.equals("jpg") || attachmentType.equals("peg") || attachmentType.equals("png")) {
- if (attachmentType.equals("peg")) {
- attachmentType = "jpg";
+ if (partname != null && partname.length() > 0) {
+ String attachmentType = partname.substring(partname.length() - 3).toLowerCase();
+ if (attachmentType.equals("jpg") || attachmentType.equals("peg") || attachmentType.equals("png")) {
+ if (attachmentType.equals("peg")) {
+ attachmentType = "jpg";
+ }
+ attachmentFName = UUID.randomUUID().toString() + "." + attachmentType;
+ filePart.write("/var/www/juick.com/i/tmp/" + attachmentFName);
+ } else {
+ throw new Exception("Wrong file type");
}
- attachmentFName = UUID.randomUUID().toString() + "." + attachmentType;
- filePart.write("/var/www/juick.com/i/tmp/" + attachmentFName);
- } else {
- throw new Exception("Wrong file type");
}
}