Copied to clipboard

Flag this post as spam?

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


  • Jason Espin 368 posts 1335 karma points
    Jul 15, 2014 @ 11:24
    Jason Espin
    1

    Umbraco media folder ids do not match Umbraco node ids

    Hi all,

    I have been working a lot with the Media service recently and seem to have stumbled across a glaring inconsistancy in the way in which Umbraco handles media. On the one hand, when I create an image under the parent directory of the media folder, the image itself will be assigned an umbraco media node id such as 1234 however, in the filesystem, this image will actually be stored under the folder name 1001. Does anybody know how I can force Umbraco to save the images within a folder that has the same ID as the media item in Umbraco as I really need to be able to update the images within the filesystem based upon this id.

    Regards,

    Jason Espin

  • Nirmit 24 posts 97 karma points
    Jul 08, 2015 @ 03:15
    Nirmit
    0

    Hi,

    Does anyone know why media folder ids are different than actual node id? And how this id is being created?

    Actually I am having one more level of complexity. I have to restore lower environment Umbraco from production database. After restoration all other node-ids are fine and continue from 'max node-id' in the database.. but media folder id starts from where lower environment left with. (i.e, if last media created in lower environment is /media/2009/xyz.jpg and in production last media is /media/6872/abc.jpg, after restoring lower environment from production database, a new media in lower environment should be /media/6873/qwe.jpg but instead, its getting created as /media/2010/qwe.jpg)

    Regards, Nirmit

  • Mark Bowser 273 posts 860 karma points c-trib
    Jul 08, 2015 @ 16:50
    Mark Bowser
    0

    I haven't tried this myself, yet, but I know that you can make custom FileSystemProviders and use them for media. One guy used one of these to make the AzureBlobStorageProvider. He uses it to store his media as blobs in the db instead of on disk. I'll bet you could use one of those IFileSystemProviders to get some control over how the media files are saved.

    https://our.umbraco.org/documentation/Extending-Umbraco/Custom-File-Systems

  • James Jackson-South 489 posts 1747 karma points c-trib
    Jul 08, 2015 @ 18:53
    James Jackson-South
    1

    Hi Jason,

    Folders are actually media items themselves so that's why they are assigned their own Id. This allows you to use something like:

    IEnumerable<IPublishedContent> images = UmbracoHelper.TypedMedia(1001).Children;
    

    To return the child media items of the folder with the id 1001.

    The path you use to return the image is parsed using routing to grab the correct item based on the id.

    What issue are you having updating items? It's perfectly possible to use the media service to update items based on Id so if you could post some code I'm sure someone here could help you out.

    @Nirmit, I'm not sure what to suggest to you as I don't understand what you are trying to do.

    @Mark, the IFileSystem providers are not actually responsible for generating the media id's. I've written an implementation for Azure Blob Storage if you want to take a closer look.

    Hope this helps

    James

Please Sign in or register to post replies

Write your reply to:

Draft