Copied to clipboard

Flag this post as spam?

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


  • Neil Hodges 338 posts 987 karma points
    Aug 26, 2021 @ 15:36
    Neil Hodges
    0

    Moving Media from Umb V7 to Umb V8

    I'm needing to move media from a V7 Umbraco site to a new install of Umbraco 8.

    Paul Seal has done a great blog post about moving the media here from v7 to v8 - https://codeshare.co.uk/blog/how-i-migrated-my-umbraco-v7-site-to-v8-part-1-media/

    I've followed this and although it does create the nodes in the Media Dashboard of the Folders, Images, and Files, each one is empty?

    I'm assuming it may have something to do with the sequential folder numbering in Umbraco 7 and the random character folder naming convention in Umbraco 8?

    enter image description here

    Has anyone successfully moved the Media from V7 to V8 before?

  • Alex Skrypnyk 6133 posts 23952 karma points MVP 7x admin c-trib
    Aug 27, 2021 @ 10:48
    Alex Skrypnyk
    0

    Hi Neil

    Did you try general content migration guide? - https://our.umbraco.com/Documentation/Fundamentals/Setup/Upgrading/migrating-to-v8

    Thanks,

    Alex

  • Paul Seal 524 posts 2889 karma points MVP 6x c-trib
    Aug 28, 2021 @ 10:45
    Paul Seal
    0

    Hi Neil Did you put the media files on disk in your v8 site?

    That should work.

  • Neil Hodges 338 posts 987 karma points
    Aug 31, 2021 @ 08:26
    Neil Hodges
    0

    Morning Paul

    Yeh moved the physical Media folder over to the new Umbraco 8 instance Media folder, so it has all the internal folders 1008.1009.1010 and so on.

    I think on the import, the URL is not being set from the XML URL value? I assume this hasn't changed in the latest version of Umbraco 8 and that you can still programmatically change that URL upon the creation of a Media item?

    I ran the other code to heal the crops and can see that mediaFromCache.Url is always empty, which would suggest it's not been set in the first place?

  • Paul Seal 524 posts 2889 karma points MVP 6x c-trib
    Sep 01, 2021 @ 06:26
    Paul Seal
    0

    Hi Neil

    I haven't tried my code for this in a while actually. It could be that something has changed in newer versions, making the code not work. Other people have told me they used the blog post and it worked for them but that was a while ago. Did you check you had set the right windows permissions on the folders?

  • Neil Hodges 338 posts 987 karma points
    Sep 01, 2021 @ 08:09
    Neil Hodges
    0

    Hi Paul

    I'm going to do some more testing this morning, with a sub-set of files and images. Stupidly I just ran the code thinking it would work Ok and shifted about 1.5GB worth of Media into the new Umbraco 8 install. So it's taken a while to remove and start again with it (lesson learned :) )

    All the folders/files have the correct folder permissions, I can create Media from the back office and it does save out Ok, Umbraco 8 now uses a random string for the media folder rather than a sequential number.

    /Media/hsgsjis/test.jpg <-- UMB 8
    /Media/1005/test.jpg <-- UMB 7
    

    I'm going to do the same as you and save out a file and an image from the back office, look at the Examine output and marry that up with what gets imported, and see if there is any difference.

    I'll report back here with what ive found.

  • Neil Hodges 338 posts 987 karma points
    Sep 02, 2021 @ 09:31
    Neil Hodges
    100

    HI

    So to follow up on this. Seems the Media path can be set Ok.

    I changed the line :

    media.SetValue("umbracoFile", JsonConvert.SerializeObject(new ImageCropperValue { Src = mediaPath }));
    

    to just:

     media.SetValue("umbracoFile", mediaPath);
    

    Seems to work fine now? All media is being added correctly. Once the import is completed (1.5GB) I'll check if the crops need healing and report back here.

  • Paul Seal 524 posts 2889 karma points MVP 6x c-trib
    Sep 02, 2021 @ 09:44
    Paul Seal
    0

    Ah yes, of course. There is a new media picker now. That will be the cause of the problem.

  • Neil Hodges 338 posts 987 karma points
    Sep 02, 2021 @ 09:46
    Neil Hodges
    0

    Yeh, upgraded to 8.16 and realised there's and new Media Picker, brought in on an earlier version.

    At least its a simple fix ;)

  • Chris Clancy 63 posts 132 karma points
    Oct 11, 2022 @ 14:55
    Chris Clancy
    0

    Hello, I've been trying a media import from Umb v7 to v10 using a method similar to the one in Paul's page. The script runs and creates all of the media noes in the backoffice with the correct names, but it doesn't actually upload any the images.

    The XML feed I am using has the URL like this:

    <Url>/media/1004/70s.jpg</Url>
    

    But I'm not sure where I should be storing the media locally. We use Azure blob storage for site media but I'm wondering if that is the problem. I have tried in the root of the project, in the /media folder and also in the wwwroot folder.

  • Chris Clancy 63 posts 132 karma points
    Oct 13, 2022 @ 13:32
    Chris Clancy
    1

    I managed to get this working in Umbraco V10 by making a small change to the code in Paul's example.

            var media = service.CreateMedia(nodeName, parentFolderId, nodeTypeAlias);
        if (nodeTypeAlias.ToLower() == "image" || nodeTypeAlias.ToLower() == "file")
            //media.SetValue("umbracoFile", JsonConvert.SerializeObject(new ImageCropperValue { Src = mediaPath }));
            media.SetValue("umbracoFile", mediaPath);
        if (key != Guid.Empty)
        {
            media.Key = key;
        }
        service.Save(media);
        return media.Id;
    

    The issue was with the nodeTypeAlias being lowercase. So that part of the code was not executing. The blob storage thing doesn't appear to be an issue. The images have now appeared in the backoffice and I simply made sure they were all pushed to the blob container and in the same location that newly created images are placed e.g 'containername/media/media'. Files also came through ok. Still some more testing to do but looking good at the moment.

    Oh and BTW, 'alt template' seems to just work in Umb10 with no additional code needed.

Please Sign in or register to post replies

Write your reply to:

Draft