mirror of
https://github.com/sismics/docs.git
synced 2024-11-21 21:47:57 +01:00
Send the correct MIME type from /file/id/data
This commit is contained in:
parent
2289f523c4
commit
9989a8967a
@ -41,6 +41,7 @@ import com.sismics.rest.exception.ClientException;
|
|||||||
import com.sismics.rest.exception.ForbiddenClientException;
|
import com.sismics.rest.exception.ForbiddenClientException;
|
||||||
import com.sismics.rest.exception.ServerException;
|
import com.sismics.rest.exception.ServerException;
|
||||||
import com.sismics.rest.util.ValidationUtil;
|
import com.sismics.rest.util.ValidationUtil;
|
||||||
|
import com.sismics.util.mime.MimeType;
|
||||||
import com.sismics.util.mime.MimeTypeUtil;
|
import com.sismics.util.mime.MimeTypeUtil;
|
||||||
import com.sun.jersey.multipart.FormDataBodyPart;
|
import com.sun.jersey.multipart.FormDataBodyPart;
|
||||||
import com.sun.jersey.multipart.FormDataParam;
|
import com.sun.jersey.multipart.FormDataParam;
|
||||||
@ -304,17 +305,21 @@ public class FileResource extends BaseResource {
|
|||||||
|
|
||||||
// Get the stored file
|
// Get the stored file
|
||||||
java.io.File storedfile;
|
java.io.File storedfile;
|
||||||
|
String mimeType;
|
||||||
if (size != null) {
|
if (size != null) {
|
||||||
storedfile = Paths.get(DirectoryUtil.getStorageDirectory().getPath(), fileId + "_" + size).toFile();
|
storedfile = Paths.get(DirectoryUtil.getStorageDirectory().getPath(), fileId + "_" + size).toFile();
|
||||||
|
mimeType = MimeType.IMAGE_JPEG; // Thumbnails are JPEG
|
||||||
if (!storedfile.exists()) {
|
if (!storedfile.exists()) {
|
||||||
storedfile = new java.io.File(getClass().getResource("/image/file.png").getFile());
|
storedfile = new java.io.File(getClass().getResource("/image/file.png").getFile());
|
||||||
|
mimeType = MimeType.IMAGE_PNG;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
storedfile = Paths.get(DirectoryUtil.getStorageDirectory().getPath(), fileId).toFile();
|
storedfile = Paths.get(DirectoryUtil.getStorageDirectory().getPath(), fileId).toFile();
|
||||||
|
mimeType = file.getMimeType();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Response.ok(storedfile)
|
return Response.ok(storedfile)
|
||||||
.header("Content-Type", file.getMimeType())
|
.header("Content-Type", mimeType)
|
||||||
.header("Expires", new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z").format(new Date().getTime() + 3600000 * 24 * 7))
|
.header("Expires", new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z").format(new Date().getTime() + 3600000 * 24 * 7))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr ng-repeat="log in logs"
|
<tr ng-repeat="log in logs"
|
||||||
ng-class="{ info: log.level == 'INFO' || log.level == 'DEBUG', warn: log.level == 'WARN', error: log.level == 'ERROR' || log.level == 'FATAL' }">
|
ng-class="{ info: log.level == 'INFO' || log.level == 'DEBUG', warning: log.level == 'WARN', error: log.level == 'ERROR' || log.level == 'FATAL' }">
|
||||||
<td>{{ log.date | date: 'yyyy-MM-dd HH:mm' }}</td>
|
<td>{{ log.date | date: 'yyyy-MM-dd HH:mm' }}</td>
|
||||||
<td>{{ log.tag }}</td>
|
<td>{{ log.tag }}</td>
|
||||||
<td class="cell-message">{{ log.message }}</td>
|
<td class="cell-message">{{ log.message }}</td>
|
||||||
|
Loading…
Reference in New Issue
Block a user