Copied to clipboard

Flag this post as spam?

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


  • Josip 195 posts 662 karma points c-trib
    Mar 21, 2019 @ 21:02
    Josip
    0

    Issue with uploading media in Umbraco 8

    Guys please help me with this. I am starting the new project and i want to use Umbraco 8, but I am running into the problems all the time. I checked documentation and it seems that nothing is changed about media service.

    I am trying to upload images in Media section with same code which i am using in Umbraco 7 (it works in Umbraco 7) but its not working.

    Also i have the same problem when i am using Upload data type but lets start with this...

    Model:

    [Required]
        public int GalleryId { get; set; }
    
        [Required]
        public IEnumerable<HttpPostedFileBase> Files { get; set; }
    

    Controller:

    [HttpPost]
        public ActionResult HandleFormSubmit(ImageGalleryFormViewModel model)
        {
            if (!ModelState.IsValid)
                return CurrentUmbracoPage();
    
            foreach (var file in model.Files)
            {
                var media = Services.MediaService.CreateMedia(file.FileName, 1051, "Image");
                media.SetValue("umbracoFile", file);
    
                Services.MediaService.Save(media);
    
            }
    
                TempData["success"] = true;
            return CurrentUmbracoPage();
        }
    
  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Mar 22, 2019 @ 06:41
    Jan Skovgaard
    0

    Hi Josip

    What error message do you get when executing the code posted if any?

    Also have you had a look in the log to see if it reveals any useful information?

    /Jan

  • Josip 195 posts 662 karma points c-trib
    Mar 22, 2019 @ 12:39
    Josip
    0

    Hi Jan,

    Yes i am getting this one Exception: Could not populate upload auto-fill properties for file '"System.Web.HttpPostedFileWrapper"'.

    System.IO.FileNotFoundException: Could not find file 'C:\Users\josip\source\repos\UmbracoOsam\UmbracoOsam\media\System.Web.HttpPostedFileWrapper'.
    File name: 'C:\Users\josip\source\repos\UmbracoOsam\UmbracoOsam\media\System.Web.HttpPostedFileWrapper'
       at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
       at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
       at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
       at Umbraco.Core.IO.PhysicalFileSystem.OpenFile(String path)
       at Umbraco.Core.IO.ShadowWrapper.OpenFile(String path)
       at Umbraco.Core.IO.FileSystemWrapper.OpenFile(String path)
       at Umbraco.Web.Media.UploadAutoFillProperties.Populate(IContentBase content, IImagingAutoFillUploadField autoFillConfig, String filepath, String culture, String segment)
    
  • Josip 195 posts 662 karma points c-trib
    Mar 26, 2019 @ 09:48
    Josip
    0

    Any idea ?

  • Thomsen 112 posts 335 karma points
    Mar 26, 2019 @ 21:03
    Thomsen
    0

    Hi Josip - we have been struggling with the same problem the whole day, using MediaService code that normally works in v7. A file/image in the media section in the specified folder is registered, but there is no thumbnail nor file sizes or anything registered, so basically a useless container to be found ... It must be a bug :-/

  • Josip 195 posts 662 karma points c-trib
    Mar 26, 2019 @ 22:39
    Josip
    0

    Hi Thomsen i hope that someone will tell us soon what is the problem. I would like to use Umbraco 8 for the new project but cant if I dont solve this thing with images :/

  • Josip 195 posts 662 karma points c-trib
    Mar 28, 2019 @ 20:53
    Josip
    0

    https://github.com/umbraco/Umbraco-CMS/issues/5102 Is this answer on our problem with uploading media?

    Can anybody share with me working example how to upload images programaticaly in Umbraco 8 , please.

    Thank you

  • Thomsen 112 posts 335 karma points
    Mar 29, 2019 @ 19:02
    Thomsen
    0

    ... I'm still waiting to see the answer too, nothing really works for this issue yet, unfortunately :-/

  • Kimbrough 11 posts 141 karma points
    Jun 10, 2019 @ 00:00
    Kimbrough
    100

    For anyone still having trouble with this one. I found this post extremely helpful.

    Working from a Surface Controller, I only needed to inject IContentTypeBaseServiceProvider in my controller's constructor because the controller had inherited access to the services.

    Working with properties on members and not Media I had to set the value on my instance of IMember, instead of an instance of IMedia, using the same pattern for HttpPostedFileBase as in the example. and Voila!

    Hope this helps.

  • Kimbrough 11 posts 141 karma points
    Jun 16, 2019 @ 13:07
    Kimbrough
    0

    I'm adding a link to this post because after finding the solution above I realized that my image was being saved but the property value did not save with crops, only the file path was being saved. So if anyone else runs into the same problem perhaps it will help.

Please Sign in or register to post replies

Write your reply to:

Draft