|
|
|
|
@ -29,6 +29,7 @@ import static de.srsoftware.umbrella.core.ModuleRegistry.userService;
@@ -29,6 +29,7 @@ import static de.srsoftware.umbrella.core.ModuleRegistry.userService;
|
|
|
|
|
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.*; |
|
|
|
|
import static de.srsoftware.umbrella.files.Constants.CONFIG_DATABASE; |
|
|
|
|
import static de.srsoftware.umbrella.files.Constants.CONFIG_FILESTORE; |
|
|
|
|
import static java.net.HttpURLConnection.HTTP_OK; |
|
|
|
|
|
|
|
|
|
public class FileModule extends BaseHandler implements FileService { |
|
|
|
|
|
|
|
|
|
@ -104,9 +105,14 @@ public class FileModule extends BaseHandler implements FileService {
@@ -104,9 +105,14 @@ public class FileModule extends BaseHandler implements FileService {
|
|
|
|
|
|
|
|
|
|
private boolean getFile(HttpExchange ex, File file) throws IOException { |
|
|
|
|
var headers = ex.getResponseHeaders(); |
|
|
|
|
//headers.add(CONTENT_TYPE, MIME_PDF);
|
|
|
|
|
var conn = file.toURI().toURL().openConnection(); |
|
|
|
|
var ct = conn.getContentType(); |
|
|
|
|
headers.add(CONTENT_TYPE, ct); |
|
|
|
|
headers.add(CONTENT_DISPOSITION,"attachment; filename=\""+file.getName()+"\""); |
|
|
|
|
return sendContent(ex,new FileInputStream(file)); |
|
|
|
|
ex.sendResponseHeaders(HTTP_OK, 0L); |
|
|
|
|
new FileInputStream(file).transferTo(ex.getResponseBody()); |
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private Map<String,Object> getDirectory(File file) throws IOException { |
|
|
|
|
|