Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-69216

Multiple file uploads through JSON API is throwing "Syntax error! Invalid char"

Details

    Description

      Description
      While uploading multiple files to Liferay through JSONWS, it didn't upload multiple files properly and I got errors as follows:

      > jodd.json.JsonException: Syntax error! Invalid char: C_offset: 1 near: "[C:\bin\lif..." [Sanitized]
      >  at jodd.json.JsonParser.syntaxError(JsonParser.java:951)
      ...
      > at com.liferay.portal.json.JSONDeserializerImpl.deserialize(JSONDeserializerImpl.java:34)
      ...
      > at com.liferay.portal.jsonwebservice.JSONWebServiceActionImpl._convertValueToParameterValue(JSONWebServiceActionImpl.java:178)
      > at com.liferay.portal.jsonwebservice.JSONWebServiceActionImpl._prepareParameters(JSONWebServiceActionImpl.java:450)

      Looking at the code,
      /Users/yasuflatland/project/liferay-portal-ee/portal-impl/src/com/liferay/portal/jsonwebservice/JSONWebServiceActionParameters.java
      in JSONWebServiceActionParameters#_collectFromRequestParameters(HttpServletRequest) method, the value is treated as File. But the value is supposed to be File array (File[]).

      UploadServletRequest receives multiple files properly but this method
      _jsonWebServiceActionParameters.put(parameterName, value)
      put file data into HashMap<String, Object> with same key so I ended up getting the last file data of multiple files uploaded. This part should be fixed to be able to handle multiple files properly.

      Steps to Reproduce

      Expected Result
      File is uploaded

      Actual Result
      a. An exception is thrown on the console running curl
      {"exception":"Syntax error! Invalid char: /\noffset: 1 near: \"[/Users/lif...\"","throwable":"jodd.json.JsonException: Syntax error! Invalid char: /\noffset: 1 near: \"[/Users/lif...\"","error":{"message":"Syntax error! Invalid char: /\noffset: 1 near: \"[/Users/lif...\

      b. An error is produced on Liferay's console

      01:34:42,397 ERROR [http-nio-8080-exec-7][JSONWebServiceServiceAction:121] Syntax error! Invalid char: /_offset: 1 near: "[/Users/lif..." [Sanitized]

      Attachments

        1. exampleFile.zip
          149 kB
        2. test.zip
          69 kB

        Activity

          People

            linda.sui Linda Sui
            brian.suh Brian Suh
            Kiyoshi Lee Kiyoshi Lee
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              3 years, 49 weeks, 5 days ago

              Packages

                Version Package
                7.3.10 DXP GA1
                Master