Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Mikael Axel Kleinwort 154 posts 499 karma points c-trib
    Nov 30, 2024 @ 16:33
    Mikael Axel Kleinwort
    0

    uSync v13.2.5 content import fails for ContentType"file" and "umbracoMediaAudio"

    Hello Kevin,

    I encounter a strange problem. I just moved some sites from U12 to U13.5.2. For this, I exported all content from the U12 site, and on an empty, clean U13 site, I re-import all settings and content items with uSync 13.5.2.

    On the new site version, there are some new properties defined for media items, which were not present during the export fromt the old site.

    Now, when I import the U12 media items (all of them NOT having those new properties in the XML), all those media items with ContentType File and umbracoMediaAudio throw a red error notification and the import stops. No log entry. The notification says:

    Error: One or more errors occurred. (Error parsing comment. Expected:
    *, got m. Path '', line 1, position 1.)
    

    Strangely, those items still seem to be present in the new site after that. When I re-export from the new site, the exported items now have the new properties in the XML, and when I re-import those items, the import finishes without error.

    This problem did not happen with any of the other media types, although the new properties where also missing in their XML. However, those other media types already had some other custom properties when exported. I just mention this in case it plays into this.

    I can't post some example XML here because it seems to mess up the editor...

    It seems to me that there is an error thrown when some properties of the media type are missing in the imported XML, however, only on the media types of "file" and "umbracoMediaAudio".

    Kind regards, Mikael

  • Mikael Axel Kleinwort 154 posts 499 karma points c-trib
    Dec 03, 2024 @ 19:04
    Mikael Axel Kleinwort
    0

    The problem was not related to uSync at all.

    I had added my own MediaSavedNotification, and when uSync tried to save a changed media item, this code threw an unhandled exception, which bubbled up client-side as the reported parsing error.

    In case anybody is interesed in the details of what I did wrong: in my MediaSavedNotification handler, I read the physical file path of the media item like this:

    ImageCropperValue? imageCropperValue = mediaItem.GetValue<ImageCropperValue>(Umbraco.Cms.Core.Constants.Conventions.Media.File);
    
    var mediaItemFileRelativePath = imageCropperValue?.Src;
    

    However, this only works for media items of type Image. For media items of type File, UmbracoMediaVectorGraphics etc., this code threw the reported error. I am now using this updated code and it seems to work fine:

    // get the umbracoFile value.
    var umbracoFile = mediaItem.GetValue<string>(Umbraco.Cms.Core.Constants.Conventions.Media.File);
    
    // get the file path from ImageCropper, if possible
    ImageCropperValue? imageCropperValue = mediaItem.GetValue<ImageCropperValue>(Umbraco.Cms.Core.Constants.Conventions.Media.File);
    
    var mediaItemFileRelativePath = imageCropperValue?.Src ?? umbracoFile;
    
Please Sign in or register to post replies

Write your reply to:

Draft