Copied to clipboard

Flag this post as spam?

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


  • Andreas Emtinger 20 posts 182 karma points
    Nov 18, 2016 @ 18:56
    Andreas Emtinger
    0

    Upload local files to Media programmatically #2

    Hi,

    I solved my own thread yesterday: https://our.umbraco.org/forum/using-umbraco-and-getting-started/81385-upload-local-files-to-media-programmatically

    But its not solved yet (couldn't find any unsolve-thread-function).

    I get no errors when using this:

    using Umbraco.Core.Models;
    

    .

    umbracoFile = mediaService.CreateMedia(fileName, parentId, mediaType);
    var streamFile = new IO.FileStream(localFile, IO.FileMode.Open);
    umbracoFile.SetValue(Constants.Conventions.Media.File, fileName, streamFile);
    mediaService.Save(umbracoFile);
    streamFile.Close();
    

    I can see the uploaded files in the BackOffice and the properties. No thumbnails (see image). enter image description here

    But the physical image is not available. No new files under Media-folder in my Web-project in Visual Studio.

    My setup:

    • Local machine/host
    • Console Application (another project in Visual Studio)

    I looked at this code, but couldn't find any difference: https://github.com/KevinJump/jumoo.usync/blob/master/jumoo.usync.content/helpers/FileHelper.cs#L236

    Please Umbraco Forum-bi, you are my only hope!

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies