Copied to clipboard

Flag this post as spam?

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


  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x admin c-trib
    Feb 20, 2010 @ 13:56
    Dave Woestenborghs
    0

    Converting upload datatype to media item

    Hi everybody,

    At the moment I have a picture gallery on my site where I have a album gallery doctype with picture doctype as children. On this picture doctype i have a image property that is a upload datatype.

    What I want to do now is convert all the pictures to a media itemtype so I can use the multiple file upload and the new pixlr datatype.

    Has anybody written a conversion like this before. Otherwise I'll have to figure it out all by myself :-D

     

    Dave

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Feb 20, 2010 @ 14:14
    Douglas Robar
    102

    I've never heard of anyone doing this before. On the plus side, the upload datatype puts the images in the /media folders so really it's a matter of updating the database so that they show up in the media section.

    Do remember to backup your database before attempting this. Okay? Okay.

    Or, depending on how many items you've already got it might be easier to simply use the multiple file upload or zipupload packages to put them in the media section directly rather than trying to migrate from one to the other.

    Let us know what you find out!

    cheers,
    doug.

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Feb 20, 2010 @ 17:12
    Morten Bock
    0

    Another options would be to just add a media itemtype to your document type, and then let your code handle both scenarios (if media exists, use that, otherwise use upload filed).

    Should be relatively easy to do, and would not require any manual work with the existing files.

  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x admin c-trib
    Feb 24, 2010 @ 21:39
    Dave Woestenborghs
    0

    I used doug's approach by creating media items through the api for files created with the upload data type.

     

  • Mike Joseph 9 posts 29 karma points
    Nov 19, 2011 @ 15:28
    Mike Joseph
    0

    What if I want to do the exact opposite? 

    Here's my scenario: I've created a section in the site called File Library. The content editor had a couple hundred PDF files that she wanted to make available. Rather than have her create a content node and upload each file individually, I had her use the Umbraco File Uploader tool to upload the documents into the Media section of the back-end. I then created a script which created a content node for each document found and then associated the file with the node using the media picker data type.

    Here's the problem: Now that all the files are in place, the content editor may add a file here or file there, so that it would be more convenient for her to just upload the file directly when adding the page. The way it's currently setup, in order to add, she has to upload to the Media section, and then create the node and then pick the medai to be associated. Similarly to remove a file (cleanly) she has to delete the content node AND delete the media file. It's a multiple step process that's far too prone to error.

    I think Morten's post will work as a short term hack, but I think I'd rather do a cleaner approach and have the files managed consistently. With a few hundred of them, it can become cluttered pretty quickly.

    Thanks in advance for the advice.

Please Sign in or register to post replies

Write your reply to:

Draft