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

Unable to detect mimetype when uploading multipart form data

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 10.10, 2021
    • Fix Version/s: 2021.25
    • Component/s: File Upload , Rest API
    • Release Notes Summary:
      Send a clear message about multipart/form-data not being supported on nuxeo 2021
    • Backlog priority:
      800
    • Upgrade notes:
      Hide

      multipart/form-data upload is not supported and will be rejected. (400 Bad Request)

      Show
      multipart/form-data upload is not supported and will be rejected. (400 Bad Request)
    • Sprint:
      nxplatform #67, nxplatform #68
    • Story Points:
      3

      Description

      When using the batch upload with multipart form data, the mimetype is not correctly detected.  In LTS 2021 it seems that multipart is no longer supported.

      Steps to Reproduce (in LTS 2021):

      1. Batch Initialization
        curl -u Administrator:Administrator -X POST http://localhost:8080/nuxeo/api/v1/upload
        
      2. Upload File (do not supply File-Name and File-Type)
        curl --location --request POST 'http://localhost:8080/nuxeo/api/v1/upload/<batchID>/0' -u Administrator:Administrator \--form 'file=@"test.pdf"'
        
      3. Create Document
        curl --location --request POST 'http://localhost:8080/nuxeo/api/v1/path/default-domain/workspaces/WS%201' -u Administrator:Administrator  -H 'Content-Type: application/json' -d '{"entity-type": "document", "type": "File",   "name": "test.pdf", "properties": {"dc:title": "test.pdf", "file:content":{"upload-batch": "<batchID>", "upload-fileId": "0"}}}'
        

      Expected Results: Document is correctly created as a pdf
      Actual Results: Main blob shows as the following

      "file:content": {
            "name": null,
            "mime-type": "application/octet-stream",
            "encoding": null,
            "digestAlgorithm": "MD5",
            "digest": "58977c2de2ca339a4ab2f997dd0ca103",
            "length": "44502",
            "data": http://localhost:8080/nuxeo/nxfile/default/05aa765d-fab2-46d0-916b-dfb4ced0686d/file:content?changeToken=1-0
          }
      

      The same results happen in 10.10 when setting this property

      <property name="nuxeo.batch.upload.multipart.disabled">true</property>
      

      When following the steps above but supplying File-Name and File-Type for a pdf at step 2, the preview is successfully generated for a pdf but the thumbnail fails with the following ImageMagick error

      2022-07-11T09:57:12,404 WARN  [Nuxeo-Work-updateThumbListener-2:4094408591503.1231213614] [org.nuxeo.ecm.platform.thumbnail.factories.ThumbnailDocumentFactory] Cannot compute document thumbnail for: 69361038-582d-489d-985c-59cc0360650a
      org.nuxeo.ecm.core.convert.api.ConversionException: Blob Key/Provider: 344065fdb48e94b8b82d9281734601fa/default, Document: DocumentModelImpl(69361038-582d-489d-985c-59cc0360650a, path=/default-domain/workspaces/WS 1/body.pdf, title=body.pdf), Thumbnail conversion failed
      	at org.nuxeo.ecm.platform.thumbnail.converter.ThumbnailDocumentConverter.convert(ThumbnailDocumentConverter.java:88) ~[nuxeo-thumbnail-2021.13.7.jar:?]
      	at org.nuxeo.ecm.core.convert.service.ConversionServiceImpl.convert(ConversionServiceImpl.java:340) ~[nuxeo-core-convert-2021.7.15.jar:?]
      	at org.nuxeo.ecm.platform.thumbnail.converter.AnyToThumbnailConverter.convert(AnyToThumbnailConverter.java:91) ~[nuxeo-thumbnail-2021.13.7.jar:?]
      	at org.nuxeo.ecm.core.convert.service.ConversionServiceImpl.convert(ConversionServiceImpl.java:340) ~[nuxeo-core-convert-2021.7.15.jar:?]
      	at org.nuxeo.ecm.platform.thumbnail.factories.ThumbnailDocumentFactory.computeThumbnail(ThumbnailDocumentFactory.java:92) [nuxeo-thumbnail-2021.13.7.jar:?]
      	at org.nuxeo.ecm.core.api.thumbnail.ThumbnailServiceImpl.computeThumbnail(ThumbnailServiceImpl.java:99) [nuxeo-core-api-2021.19.10.jar:?]
      	at org.nuxeo.ecm.core.api.thumbnail.ThumbnailAdapter.computeThumbnail(ThumbnailAdapter.java:58) [nuxeo-core-api-2021.19.10.jar:?]
      	at org.nuxeo.ecm.platform.thumbnail.listener.ThumbnailHelper.createThumbnailIfNeeded(ThumbnailHelper.java:80) [nuxeo-thumbnail-2021.13.7.jar:?]
      	at org.nuxeo.ecm.platform.thumbnail.listener.UpdateThumbnailListener.processDoc(UpdateThumbnailListener.java:54) [nuxeo-thumbnail-2021.13.7.jar:?]
      	at org.nuxeo.ecm.platform.thumbnail.listener.UpdateThumbnailListener.handleEvent(UpdateThumbnailListener.java:84) [nuxeo-thumbnail-2021.13.7.jar:?]
      	at org.nuxeo.ecm.core.event.impl.AsyncEventExecutor$ListenerWork.work(AsyncEventExecutor.java:209) [nuxeo-core-event-2021.20.4.jar:?]
      	at org.nuxeo.ecm.core.work.AbstractWork.runWorkWithTransaction(AbstractWork.java:536) [nuxeo-core-event-2021.20.4.jar:?]
      	at org.nuxeo.ecm.core.work.AbstractWork.run(AbstractWork.java:387) [nuxeo-core-event-2021.20.4.jar:?]
      	at org.nuxeo.ecm.core.work.WorkHolder.run(WorkHolder.java:57) [nuxeo-core-event-2021.20.4.jar:?]
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
      	at java.lang.Thread.run(Thread.java:829) [?:?]
      Caused by: org.nuxeo.ecm.platform.commandline.executor.api.CommandException: Error code 1 after 0.05s for command: convert -define registry:temporary-path=#{nuxeo.tmp.dir} -quiet -strip -thumbnail #{size} -background transparent -gravity center -format png -quality 75 #{inputFilePath}[0] #{outputFilePath}, parameters: java.io.tmpdir=/Users/nicolepeacock/nuxeo_server_instances/nuxeo-server-tomcat-2021.1_ootb_v2/tmp, nuxeo.tmp.dir=/Users/nicolepeacock/nuxeo_server_instances/nuxeo-server-tomcat-2021.1_ootb_v2/tmp, size=1000x1000, inputFilePath=/Users/nicolepeacock/nuxeo_server_instances/nuxeo-server-tomcat-2021.1_ootb_v2/nxserver/data/binaries/data/34/40/344065fdb48e94b8b82d9281734601fa, outputFilePath=/Users/nicolepeacock/nuxeo_server_instances/nuxeo-server-tomcat-2021.1_ootb_v2/tmp/nxblob-2799946530023592745.png
      output: convert: no decode delegate for this image format `' @ error/constitute.c/ReadImage/575.
        convert: no images defined `/Users/nicolepeacock/nuxeo_server_instances/nuxeo-server-tomcat-2021.1_ootb_v2/tmp/nxblob-2799946530023592745.png' @ error/convert.c/ConvertImageCommand/3229.
      

      When supplying File-Name and File-Type for an image (Picture doctype), get the following error

      2022-07-11T10:01:35,709 ERROR [bulk/recomputeViewsPool-00] [org.nuxeo.ecm.platform.picture.ImagingComponent] Failed to get ImageInfo for file download.jpg
      org.nuxeo.ecm.platform.commandline.executor.api.CommandException: Error code 1 after 0.06s for command: identify -define registry:temporary-path=#{nuxeo.tmp.dir} -quiet -ping -format '%m %w %h %z %[colorspace]' #{inputFilePath}[0], parameters: java.io.tmpdir=/Users/nicolepeacock/nuxeo_server_instances/nuxeo-server-tomcat-2021.1_ootb_v2/tmp, nuxeo.tmp.dir=/Users/nicolepeacock/nuxeo_server_instances/nuxeo-server-tomcat-2021.1_ootb_v2/tmp, inputFilePath=/Users/nicolepeacock/nuxeo_server_instances/nuxeo-server-tomcat-2021.1_ootb_v2/tmp/nxblob-12404795431236308074.jpg
      output: identify: Not a JPEG file: starts with 0x2d 0x2d `/Users/nicolepeacock/nuxeo_server_instances/nuxeo-server-tomcat-2021.1_ootb_v2/tmp/nxblob-12404795431236308074.jpg' @ error/jpeg.c/JPEGErrorHandler/339.
        JPG 0 0 16 sRGB
      

        Attachments

        1. download.jpg
          11 kB
          Nicole Peacock
        2. test.pdf
          1 kB
          Nicole Peacock

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: