Uploaded image for project: 'Nuxeo Platform'
  1. Nuxeo Platform
  2. NXP-26780

Initialize filename with blob name in FileImporterContext

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 10.10
    • Fix Version/s: 11.1
    • Component/s: File Upload
    • Backlog priority:
      500
    • Upgrade notes:
      Hide

      Since 11.1 if the file name of the FileImporterContext is missing then it will be filled with the Blob's file name.

      This means that you no longer need to add control to avoid an empty filename outside of the FileImporterContext class, for example see the snippet code below  AudioImporter

      // code placeholder
      @@ -57,8 +56,7 @@ public class AudioImporter extends AbstractFileImporter {
               CoreSession session = context.getSession();
               Blob blob = context.getBlob();
       
      -        String filename = FileManagerUtils.fetchFileName(
      -                StringUtils.defaultIfBlank(context.getFileName(), blob.getFilename()));
      +        String filename = FileManagerUtils.fetchFileName(context.getFileName());
      

       

      Show
      Since 11.1 if the file name of the  FileImporterContext is missing then it will be filled with the Blob's file name. This means that you no longer need to add control to avoid an empty filename outside of the FileImporterContext class, for example see the snippet code below  AudioImporter :  // code placeholder @@ -57,8 +56,7 @@ public class AudioImporter extends AbstractFileImporter { CoreSession session = context.getSession(); Blob blob = context.getBlob(); - String filename = FileManagerUtils.fetchFileName( - StringUtils.defaultIfBlank(context.getFileName(), blob.getFilename())); + String filename = FileManagerUtils.fetchFileName(context.getFileName());  
    • Sprint:
      nxplatform 11.1.12, nxplatform 11.1.13
    • Story Points:
      2

      Description

      A custom filemanager plugin needs to be aware of the implementation logic of FileImporterContext in order to get the blob name

      This can be prevented by initializing filename with the blob filename on the following line:

      https://github.com/nuxeo/nuxeo/blob/7a403fcb27ba826e5567840f108e17bd53fabab2/nuxeo-services/nuxeo-platform-filemanager-api/src/main/java/org/nuxeo/ecm/platform/filemanager/api/FileImporterContext.java#L113

      Otherwise you need to implement the same logic in every filemanager plugins:

      • call getFileName
      • if null, call getBlob().filename

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 day
                1d

                  PagerDuty

                  Error rendering 'com.pagerduty.jira-server-plugin:PagerDuty'. Please contact your Jira administrators.