You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Bonita Web Server新建文件夹及Bonita BPM文件上传技术咨询

Bonita BPM: Web Server Directory Mapping & File Upload Implementation

Hey there! As someone who’s worked with Bonita BPM’s file handling workflows, let’s break down your questions and fix the issues you’re facing:

Is your adjusted logic (using a web server directory) feasible?

Absolutely—your core direction is correct! The problem you’re hitting right now is using file:/// to access the Tomcat server's directory, which won’t work for a key reason:

Browsers enforce strict security restrictions that block file:/// URLs from accessing files on remote servers (even if the server is on the same machine as the browser). file:/// only points to the client's local file system, not the server's.

To fix this, you need to map your server-side folder as a virtual web path in Tomcat so you can access it via HTTP/HTTPS instead of file:///. Here’s how:

Step 1: Map the server folder to a Tomcat virtual path

You have two easy ways to do this:

  • Option 1: Edit server.xml
    Open Tomcat's conf/server.xml, find the <Host> tag (usually under <Engine name="Catalina" defaultHost="localhost">), and add this context entry:

    <Context docBase="/absolute/path/to/your/test/folder" path="/bonita-storage" reloadable="true"/>
    

    Replace /absolute/path/to/your/test/folder with the actual physical path of your server folder, and /bonita-storage with a path name you’ll use to access it via web.

  • Option 2: Create a context XML file
    In Tomcat's conf/Catalina/localhost folder, create a new XML file (e.g., bonita-storage.xml) with this content:

    <Context docBase="/absolute/path/to/your/test/folder" reloadable="true"/>
    

    Now you can access the folder via http://your-tomcat-domain:port/bonita-storage/—this is the URL you should link in your Bonita variables, not file:///.

Can you implement creating folders + uploading files from local directories?

100% feasible! You’ll need to combine Bonita’s built-in components with some server-side logic. Here’s a step-by-step workflow:

1. Add a file upload component to your Bonita form

  • In your Bonita process form, drag and drop a File Input component. This lets users select local files to upload to Bonita’s temporary storage.

2. Add a script task to create server folders

  • In your Bonita process, insert a Java Script Task after the form step. Use Java code to create your target folder on the server:
    import java.io.File;
    
    String targetDir = "/absolute/path/to/your/test/folder/new-subfolder";
    File dir = new File(targetDir);
    if (!dir.exists()) {
        dir.mkdirs(); // Creates parent folders if needed
    }
    
    Make sure the user running Tomcat has read/write permissions for this directory!

3. Move uploaded files to the server folder

  • Extend the same script task to copy the uploaded file from Bonita’s temporary storage to your server folder. Bonita stores uploaded files in a temp location you can access via the form’s file variable:
    import java.nio.file.Files;
    import java.nio.file.Paths;
    import java.nio.file.StandardCopyOption;
    
    // Get the uploaded file from Bonita's temp storage
    org.bonitasoft.engine.api.ProcessAPI processAPI = org.bonitasoft.engine.api.TenantAPIAccessor.getProcessAPI(apiSession);
    org.bonitasoft.engine.bpm.document.Document document = processAPI.getDocumentInstance(documentId); // Replace documentId with your file variable's ID
    String tempFilePath = document.getContentStorageId(); // Path to Bonita's temp file
    
    // Define target path
    String targetFilePath = targetDir + "/" + document.getFileName();
    
    // Copy the file
    Files.copy(Paths.get(tempFilePath), Paths.get(targetFilePath), StandardCopyOption.REPLACE_EXISTING);
    

4. Access the files via the virtual web path

Once the file is in the mapped server folder, you can display it in Bonita using the HTTP URL (e.g., http://your-tomcat-domain:port/bonita-storage/new-subfolder/your-file.pdf).

Quick tips to avoid common issues

  • Adjust Bonita's upload size limit: If you need to upload large files, edit bonita-tenant-portal.properties and update org.bonitasoft.web.portal.maxUploadSize to a higher value (e.g., 10485760 for 10MB).
  • Cluster environments: If you’re running Bonita in a cluster, use a shared storage solution (like NFS) for your server folder so all nodes can access the files.
  • Test permissions first: Run a quick test to ensure Tomcat can read/write to your target directory—permission errors are the most common cause of failed file operations.

内容的提问来源于stack exchange,提问作者Jane

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 04:14:17