Returns correct file variation from /file/id/data

This commit is contained in:
jendib 2013-08-18 13:52:29 +02:00
parent d3f59554f8
commit 77c5a10aba
2 changed files with 3 additions and 5 deletions

View File

@ -41,7 +41,6 @@ import com.sismics.rest.exception.ClientException;
import com.sismics.rest.exception.ForbiddenClientException;
import com.sismics.rest.exception.ServerException;
import com.sismics.rest.util.ValidationUtil;
import com.sismics.util.ImageUtil;
import com.sismics.util.mime.MimeTypeUtil;
import com.sun.jersey.multipart.FormDataBodyPart;
import com.sun.jersey.multipart.FormDataParam;
@ -306,9 +305,8 @@ public class FileResource extends BaseResource {
// Get the stored file
java.io.File storedfile;
if (size != null) {
if (ImageUtil.isImage(file.getMimeType())) {
storedfile = Paths.get(DirectoryUtil.getStorageDirectory().getPath(), fileId + "_" + size).toFile();
} else {
storedfile = Paths.get(DirectoryUtil.getStorageDirectory().getPath(), fileId + "_" + size).toFile();
if (!storedfile.exists()) {
storedfile = new java.io.File(getClass().getResource("/image/file.png").getFile());
}
} else {

View File

@ -416,6 +416,6 @@ public class TestDocumentResource extends BaseJerseyTest {
Assert.assertEquals(Status.OK, Status.fromStatusCode(response.getStatus()));
InputStream is = response.getEntityInputStream();
byte[] fileBytes = ByteStreams.toByteArray(is);
Assert.assertEquals(3457, fileBytes.length);
Assert.assertEquals(33691, fileBytes.length);
}
}