1
0
mirror of https://github.com/sismics/docs.git synced 2025-12-31 02:22:27 +00:00

Closes #116: Allow all file types

This commit is contained in:
jendib
2016-11-20 18:41:42 +01:00
parent c99b1a1867
commit b36d08db8e
7 changed files with 56 additions and 12 deletions

View File

@@ -41,6 +41,7 @@ import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.text.MessageFormat;
@@ -129,10 +130,7 @@ public class FileResource extends BaseResource {
} catch (IOException e) {
throw new ServerException("ErrorGuessMime", "Error guessing mime type", e);
}
if (mimeType == null) {
throw new ClientException("InvalidFileType", "File type not recognized");
}
// Validate quota
if (user.getStorageCurrent() + fileData.length > user.getStorageQuota()) {
throw new ClientException("QuotaReached", "Quota limit reached");
@@ -535,7 +533,11 @@ public class FileResource extends BaseResource {
mimeType = MimeType.IMAGE_JPEG; // Thumbnails are JPEG
decrypt = true; // Thumbnails are encrypted
if (!Files.exists(storedFile)) {
storedFile = Paths.get(getClass().getResource("/image/file.png").getFile());
try {
storedFile = Paths.get(getClass().getResource("/image/file.png").toURI());
} catch (URISyntaxException e) {
// Ignore
}
mimeType = MimeType.IMAGE_PNG;
decrypt = false;
}

View File

@@ -39,7 +39,7 @@
</dl>
<div ng-file-drop drag-over-class="bg-success" ng-multiple="true" allow-dir="false" ng-model="dropFiles"
accept="image/*,application/pdf,application/zip" ng-file-change="fileDropped($files, $event, $rejectedFiles)">
ng-file-change="fileDropped($files, $event, $rejectedFiles)">
<div class="row upload-zone" ui-sortable="fileSortableOptions" ng-model="files">
<div class="col-xs-6 col-sm-4 col-md-4 col-lg-3 text-center" ng-repeat="file in files">
<div class="thumbnail" ng-if="file.id">