Uploaded image for project: 'eZ Publish / Platform'
  1. eZ Publish / Platform
  2. EZP-23837

Impossible to set the value of a Media field

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Medium Medium
    • 2015.01
    • 2014.11, 5.4.0
    • Platform > REST API v2
    • None
    • Pollux Core S3

    Description

      It's impossible to update the value of a Media field using the REST API.

      For example such a request (with a valid base64 encoded content of course):

      curl 'http://ezpublish5.loc/api/ezp/v2/content/objects/291/versions/12' -X PATCH -H 'X-CSRF-Token: eDglCMT_wLJvYbc_jDElfqOThXIYbQQly9TVOfIG8PE' -H 'Content-Type: application/vnd.ez.api.VersionUpdate+json' -H 'Accept: application/vnd.ez.api.Version+json' -H 'Cookie: eZSESSID=uv9u3dapglfuplqdp14hhigtp1' --data-binary '{"VersionUpdate":{"modificationDate":"2014-12-26T14:40:26.070Z","initialLanguageCode":"eng-GB","fields":{"field":[{"id":1646,"fieldDefinitionIdentifier":"name","languageCode":"eng-GB","fieldValue":"Test"},{"id":1647,"fieldDefinitionIdentifier":"video","languageCode":"eng-GB","fieldValue":{"fileName":"Exemple.ogg","data":"BASE64ENCODED CONTENT"}}]}}}'
      

      anwsers with a 500 error:

      {
          "ErrorMessage": {
              "_media-type": "application\/vnd.ez.api.ErrorMessage+json",
              "errorCode": 500,
              "errorMessage": "Internal Server Error",
              "errorDescription": "Property 'data' not found on class 'eZ\\Publish\\Core\\FieldType\\Media\\Value'",
              "trace": "#0 \/home\/dp\/dev\/ezpublish-community\/vendor\/ezsystems\/ezpublish-kernel\/eZ\/Publish\/Core\/FieldType\/BinaryBase\/Value.php(124): eZ\\Publish\\API\\Repository\\Values\\ValueObject->__set('data', 'T2dnUwACAAAAAAA...')\n#1 \/home\/dp\/dev\/ezpublish-community\/vendor\/ezsystems\/ezpublish-kernel\/eZ\/Publish\/API\/Repository\/Values\/ValueObject.php(40): eZ\\Publish\\Core\\FieldType\\BinaryBase\\Value->__set('data', 'T2dnUwACAAAAAAA...')\n#2 \/home\/dp\/dev\/ezpublish-community\/vendor\/ezsystems\/ezpublish-kernel\/eZ\/Publish\/Core\/FieldType\/BinaryBase\/Value.php(87): eZ\\Publish\\API\\Repository\\Values\\ValueObject->__construct(Array)\n#3 \/home\/dp\/dev\/ezpublish-community\/vendor\/ezsystems\/ezpublish-kernel\/eZ\/Publish\/Core\/FieldType\/Media\/Type.php(136): eZ\\Publish\\Core\\FieldType\\BinaryBase\\Value->__construct(Array)\n#4 \/home\/dp\/dev\/ezpublish-community\/vendor\/ezsystems\/ezpublish-kernel\/eZ\/Publish\/Core\/FieldType\/BinaryBase\/Type.php(192): eZ\\Publish\\Core\\FieldType\\Media\\Type->createValue(Array)\n#5 \/home\/dp\/dev\/ezpublish-community\/vendor\/ezsystems\/ezpublish-kernel\/eZ\/Publish\/Core\/Repository\/Values\/ContentType\/FieldType.php(189): eZ\\Publish\\Core\\FieldType\\BinaryBase\\Type->fromHash(Array)\n#6 \/home\/dp\/dev\/ezpublish-community\/vendor\/ezsystems\/ezpublish-kernel\/eZ\/Publish\/Core\/REST\/Common\/Input\/FieldTypeParser.php(95): eZ\\Publish\\Core\\Repository\\Values\\ContentType\\FieldType->fromHash(Array)\n#7 \/home\/dp\/dev\/ezpublish-community\/vendor\/ezsystems\/ezpublish-kernel\/eZ\/Publish\/Core\/REST\/Common\/Input\/FieldTypeParser.php(74): eZ\\Publish\\Core\\REST\\Common\\Input\\FieldTypeParser->parseValue('ezmedia', Array)\n#8 \/home\/dp\/dev\/ezpublish-community\/vendor\/ezsystems\/ezpublish-kernel\/eZ\/Publish\/Core\/REST\/Server\/Input\/Parser\/VersionUpdate.php(96): eZ\\Publish\\Core\\REST\\Common\\Input\\FieldTypeParser->parseFieldValue('291', 'video', Array)\n#9 \/home\/dp\/dev\/ezpublish-community\/vendor\/ezsystems\/ezpublish-kernel\/eZ\/Publish\/Core\/REST\/Common\/Input\/ParsingDispatcher.php(79): eZ\\Publish\\Core\\REST\\Server\\Input\\Parser\\VersionUpdate->parse(Array, Object(eZ\\Publish\\Core\\REST\\Common\\Input\\ParsingDispatcher))\n#10 \/home\/dp\/dev\/ezpublish-community\/vendor\/ezsystems\/ezpublish-kernel\/eZ\/Publish\/Core\/REST\/Common\/Input\/Dispatcher.php(115): eZ\\Publish\\Core\\REST\\Common\\Input\\ParsingDispatcher->parse(Array, 'application\/vnd...')\n#11 \/home\/dp\/dev\/ezpublish-community\/vendor\/ezsystems\/ezpublish-kernel\/eZ\/Publish\/Core\/REST\/Server\/Controller\/Content.php(479): eZ\\Publish\\Core\\REST\\Common\\Input\\Dispatcher->parse(Object(eZ\\Publish\\Core\\REST\\Common\\Message))\n#12 [internal function]: eZ\\Publish\\Core\\REST\\Server\\Controller\\Content->updateVersion('291', '12')\n#13 \/home\/dp\/dev\/ezpublish-community\/vendor\/symfony\/symfony\/src\/Symfony\/Component\/HttpKernel\/HttpKernel.php(145): call_user_func_array(Array, Array)\n#14 \/home\/dp\/dev\/ezpublish-community\/vendor\/symfony\/symfony\/src\/Symfony\/Component\/HttpKernel\/HttpKernel.php(66): Symfony\\Component\\HttpKernel\\HttpKernel->handleRaw(Object(Symfony\\Component\\HttpFoundation\\Request), 1)\n#15 \/home\/dp\/dev\/ezpublish-community\/vendor\/symfony\/symfony\/src\/Symfony\/Component\/HttpKernel\/DependencyInjection\/ContainerAwareHttpKernel.php(64): Symfony\\Component\\HttpKernel\\HttpKernel->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#16 \/home\/dp\/dev\/ezpublish-community\/vendor\/symfony\/symfony\/src\/Symfony\/Component\/HttpKernel\/Kernel.php(185): Symfony\\Component\\HttpKernel\\DependencyInjection\\ContainerAwareHttpKernel->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#17 \/home\/dp\/dev\/ezpublish-community\/web\/index.php(77): Symfony\\Component\\HttpKernel\\Kernel->handle(Object(Symfony\\Component\\HttpFoundation\\Request))\n#18 {main}",
              "file": "\/home\/dp\/dev\/ezpublish-community\/vendor\/ezsystems\/ezpublish-kernel\/eZ\/Publish\/API\/Repository\/Values\/ValueObject.php",
              "line": 87
          }
      }
      

      This is happening because unlike for BinaryFile and Image fields, the Media field type processor does not extend the BinaryInputProcessor which takes care of extracting the data entry in the field value to create a file on the disk.

      Attachments

        Activity

          People

            Unassigned Unassigned
            damien.pobel-obsolete@ez.no Damien Pobel (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

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