Search in sources :

Example 1 with TusFileUploadService

use of me.desair.tus.server.TusFileUploadService in project servoy-client by Servoy.

the class TusServlet method init.

@Override
public void init(ServletConfig config) throws ServletException {
    super.init(config);
    Settings settings = Settings.getInstance();
    String uploadDir = settings.getProperty("servoy.ng_web_client.temp.uploadir");
    long maxUpload = Utils.getAsLong(settings.getProperty("servoy.webclient.maxuploadsize", "0"), false);
    File fileUploadDir = null;
    if (uploadDir != null) {
        fileUploadDir = new File(uploadDir);
        if (!fileUploadDir.exists() && !fileUploadDir.mkdirs()) {
            fileUploadDir = null;
            Debug.error("Couldn't use the property 'servoy.ng_web_client.temp.uploadir' value: '" + uploadDir + "', directory could not be created or doesn't exists");
        }
    }
    tusFileUploadService = new TusFileUploadService().withUploadURI(config.getServletContext().getContextPath() + "/tus/upload/[0-9]+/.+/.+/.+/");
    if (fileUploadDir != null) {
        try {
            tusFileUploadService = tusFileUploadService.withStoragePath(fileUploadDir.getCanonicalPath());
        } catch (IOException e) {
            throw new ServletException(e);
        }
    }
    if (maxUpload > 0) {
        tusFileUploadService = tusFileUploadService.withMaxUploadSize(Long.valueOf(maxUpload));
    }
}
Also used : TusFileUploadService(me.desair.tus.server.TusFileUploadService) ServletException(javax.servlet.ServletException) IOException(java.io.IOException) IFile(com.servoy.j2db.plugins.IFile) File(java.io.File) Settings(com.servoy.j2db.util.Settings)

Aggregations

IFile (com.servoy.j2db.plugins.IFile)1 Settings (com.servoy.j2db.util.Settings)1 File (java.io.File)1 IOException (java.io.IOException)1 ServletException (javax.servlet.ServletException)1 TusFileUploadService (me.desair.tus.server.TusFileUploadService)1