1
0
-1

I want to upload files from joget to a server outside of joget and retrieve those files

    CommentAdd your comment...

    1 answer

    1.  
      1
      0
      -1

      Good Day Paik,

      Basically the concept of of file upload can be understood with this concept : 
      Files uploaded in the form is saved in \wflow\app_formuploads .

      1 ) If you want to save to a different folder, you can define the path in general settings, if not mistaken.

      general settings > Uploaded File Storage Base Path


      2 )There is also a KB for uploading to external storage integrated with Amazon S3 : File Upload Form Element Integrated with Amazon S3

      3 )You can also try out this method File handling in Bean Shell Form Store Binder.

      The provided code from the link above currently stores uploaded files in the local filesystem. Here's how you can alter it to store them on an external server:

      1. Choose a Storage Solution:

      There are several ways to store files on an external server. Here are some options:

      • Cloud Storage: Services like Amazon S3, Google Cloud Storage, or Microsoft Azure Blob Storage offer secure and scalable storage solutions.
      • FTP Server: You can use an FTP server to upload files. However, FTP is not very secure and may not be ideal for sensitive data.
      • WebDAV Server: WebDAV allows you to access remote storage using standard HTTP methods like PUT and DELETE.

      2. Modify the storeFileFromFormRowSet method:

      This method currently uses FileUtil.storeFileFromFormRowSet to store files locally. You'll need to replace that with code specific to your chosen storage solution. Here's a general outline:

      Java

      private void storeFilesOnExternalServer(FormRowSet rows, String tableName, String primaryKeyValue) throws Exception {
        // Loop through each row with uploaded files
        for (FormRow row : rows) {
          String fileField = "files"; // Replace with your actual file field name
          String files = row.getProperty(fileField);
          if (files == null || files.isEmpty()) {
            continue;
          }
          
          String[] filePaths = files.split(";");
          for (String filePath : filePaths) {
            // Get the actual file content (replace with your logic)
            byte[] fileContent = getFileContent(filePath);
            
            // Upload the file to the external server (replace with your logic)
            uploadFileToExternalServer(filePath, fileContent, tableName, primaryKeyValue);
          }
        }
      }


      Hope it helps
      Cheers!

        CommentAdd your comment...