peparing for file upload on server side

This commit is contained in:
2025-09-30 15:17:00 +02:00
parent 06118365b8
commit f9941bceba
9 changed files with 34 additions and 11 deletions

View File

@@ -1,6 +1,7 @@
/* © SRSoftware 2025 */
package de.srsoftware.umbrella.files;
import static de.srsoftware.tools.MimeType.MIME_FORM_DATA;
import static de.srsoftware.umbrella.core.ConnectionProvider.connect;
import static de.srsoftware.umbrella.core.Constants.*;
import static de.srsoftware.umbrella.core.ModuleRegistry.*;
@@ -220,6 +221,13 @@ public class FileModule extends BaseHandler implements FileService {
if (!path.empty()) filename += "/"+URLDecoder.decode(path.toString(),UTF_8);
if (uid != user.id() && !fileDb.isPermitted(user,filename)) throw forbidden("You are not allowed to access {0}",filename);
var file = new File(baseDir+filename);
var contentType = contentType(ex).orElse(null);
if (MIME_FORM_DATA.equals(contentType)) { // file upload
// TODO: create parent directory if it does not exist
// TODO: create file and write content
return false;
}
if (file.exists()) throw unprocessable("{0} already exists!",filename);
try {
file.mkdirs();