Copied to clipboard

Flag this post as spam?

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


  • Owen Hope 119 posts 140 karma points
    Oct 19, 2011 @ 19:03
    Owen Hope
    0

    Upload Media - Create Umbraco Document

    Hi,

    I have a form with a media upload field, and I want to on submit save the field as a Umbraco Document (I have mapped all fields).

    Currently with the default workflow the media uploader does not handle this. Im guessing I will need to write a custom workflow.

    Can I edit the existing workflow for "Save as Umbraco Document"? 

    Any help getting the ball rolling on this is much appreciated.

     

    Owen

  • Comment author was deleted

    Oct 20, 2011 @ 09:15

    Hi Owen,

    Well you'll need a custom workflow to do that, but you can simply start by modifying the existing workflow code, check the sourcecode for the default providers: 

    http://our.umbraco.org/FileDownload?id=2922

  • Owen Hope 119 posts 140 karma points
    Oct 20, 2011 @ 19:06
    Owen Hope
    0

    Hi Tim,

    Thanks for the advice.

    I opened up SaveAsUmbracoNode.cs - and am now looking through the code.

    Is this where I need to implement my Upload logic?

    DocumentType dt = new DocumentType(dtId);
    
                if (dt != null) {                
    
                    Document d = Document.MakeNew(nameMapping, dt, new umbraco.BusinessLogic.User(0), root);
    
                    foreach (Property p in d.getProperties) {
    
                        try {
    
                            if (mappings.ContainsKey(p.PropertyType.Alias)) {
                                switch (((BaseDataType)p.PropertyType.DataTypeDefinition.DataType).DBType)
                                {
                                    case DBTypes.Date:
                                        p.Value = DateTime.Parse(mappings[p.PropertyType.Alias]);
                                        break;
                                    case DBTypes.Integer:
                                        string v = mappings[p.PropertyType.Alias];
                                        if (v.ToLower() == "true" || v.ToLower() == "false")
                                            p.Value = bool.Parse(v);
                                        else
                                            p.Value = int.Parse(mappings[p.PropertyType.Alias]);
                                        break;
                                    default:
                                        p.Value = mappings[p.PropertyType.Alias];
                                        break;
                                }
                            }
    
                        } catch(Exception ex) {
                            LogHelper.Debug(ex.ToString());
                        }
                    }
    
                    d.Save();

    Is there another Workflow that I can look at to get a better idea of how to map these values?

    Cheers,


    Owen

  • Owen Hope 119 posts 140 karma points
    Oct 27, 2011 @ 00:40
    Owen Hope
    0

    Bump!

  • Comment author was deleted

    Oct 27, 2011 @ 09:08

    Well the upload has already happened if you have an upload field on your form.

    So all you need to do is set the upload property value on the document to the path of the file...

  • Jason Prothero 422 posts 1243 karma points c-trib
    Feb 11, 2013 @ 05:12
    Jason Prothero
    0

    Owen,

    Did you ever create a workflow to create a media item from a file upload?  Care to share your solution?

     

    Thanks,

    Jason

  • keilo 568 posts 1023 karma points
    Jun 14, 2014 @ 11:13
    keilo
    0

    Hi Jason

    Have you figured out on how to create media item from Contour file upload, or map the Contour file upload to a document type Upload field?

    Would appreciate if you can share the source if you have already figured out a solution. my email is akeilox (a) gmail.com

    many thanks in advance!

  • Jason Prothero 422 posts 1243 karma points c-trib
    Jun 16, 2014 @ 18:53
    Jason Prothero
    0

    I was able to get this working.  The tricky part was getting the crops to generate.  I'll have to see what I have in BitBucket.

     

    Thanks,

    Jason

  • keilo 568 posts 1023 karma points
    Jun 18, 2014 @ 17:00
    keilo
    0

    Thats great news Jason! Did you manage to solve the crop generation as well?

    Looking forward to your solution!

    cheers

  • Jason Prothero 422 posts 1243 karma points c-trib
    Jun 18, 2014 @ 20:05
    Jason Prothero
    0

    The crop generation was handled by DAMP.  It auto-creates crops for you if installed and configured correctly.

     

    -Jason

  • keilo 568 posts 1023 karma points
    Jun 22, 2014 @ 13:35
    keilo
    0

    Hi again Jason

    Would you be able to share your solution? Im looking forward to implement Contour file upload linking to a document type Upload field or an alternate approach.

    many thanks in advance!

Please Sign in or register to post replies

Write your reply to:

Draft