Fix default thumbnail

This commit is contained in:
jendib 2013-08-21 01:05:59 +02:00
parent db7a9f0e4a
commit 4e22111f38
2 changed files with 4 additions and 0 deletions

View File

@ -336,6 +336,7 @@ public class FileResource extends BaseResource {
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; mimeType = MimeType.IMAGE_PNG;
decrypt = false;
} }
} else { } else {
storedfile = Paths.get(DirectoryUtil.getStorageDirectory().getPath(), fileId).toFile(); storedfile = Paths.get(DirectoryUtil.getStorageDirectory().getPath(), fileId).toFile();

View File

@ -18,6 +18,8 @@ import org.junit.Test;
import com.google.common.io.ByteStreams; import com.google.common.io.ByteStreams;
import com.sismics.docs.core.util.DirectoryUtil; import com.sismics.docs.core.util.DirectoryUtil;
import com.sismics.docs.rest.filter.CookieAuthenticationFilter; import com.sismics.docs.rest.filter.CookieAuthenticationFilter;
import com.sismics.util.mime.MimeType;
import com.sismics.util.mime.MimeTypeUtil;
import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.ClientResponse.Status; import com.sun.jersey.api.client.ClientResponse.Status;
import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.WebResource;
@ -296,6 +298,7 @@ public class TestDocumentResource extends BaseJerseyTest {
Assert.assertEquals(Status.OK, Status.fromStatusCode(response.getStatus())); Assert.assertEquals(Status.OK, Status.fromStatusCode(response.getStatus()));
InputStream is = response.getEntityInputStream(); InputStream is = response.getEntityInputStream();
byte[] fileBytes = ByteStreams.toByteArray(is); byte[] fileBytes = ByteStreams.toByteArray(is);
Assert.assertEquals(MimeType.IMAGE_JPEG, MimeTypeUtil.guessMimeType(fileBytes));
Assert.assertEquals(33691, fileBytes.length); Assert.assertEquals(33691, fileBytes.length);
} }
} }