Copied to clipboard

Flag this post as spam?

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


  • AmandaEly 123 posts 379 karma points
    Apr 19, 2015 @ 12:21
    AmandaEly
    0

    Images saved via mediaservice in console app end up in wrong place

    Hi,

    I am now able to use the mediaservice through a console application. I am using Umbraco.Core.Models to access the correct overload of Media.SetValue. One problem that is stopping this working at all, is that the images are being saved into the bin directory of the console application with completely inappropriate folder name. For example, a new image is saved to bin/Debug/media/1004. 

    I have an idea that I may need to tweak the FileSystemProviders.config file in the console application so that new images get placed in the Umbraco website. Say

    <Provider alias="media" type="Umbraco.Core.IO.PhysicalFileSystem, Umbraco.Core">

        <Parameters>

          <add key="virtualRoot" value="~/media/" />

        </Parameters>

      </Provider>

    replacing the virtual root with the absolute address of the umbraco website media folder. Would that be enough to get the new direcoty named with the id of the new IMedia object?

  • AmandaEly 123 posts 379 karma points
    Apr 19, 2015 @ 12:56
    AmandaEly
    0

    I tried replacing the virtual path by an absolute path but that lead to a TargetInvocationException

    The virtualRoot argument must be a virtual path and start with '~/'

    "C://Websites/UmbracoSites/ElyRunners_2015/ElyRunners/ElyRunners/media/" isn't virtual, of course. Not sure where to go now.

  • Lennart Stoop 304 posts 842 karma points
    Apr 19, 2015 @ 13:13
    Lennart Stoop
    100

    The provider allows you to configure the root as a UNC path:

    <add key="rootPath" value="C://Websites/UmbracoSites/ElyRunners_2015/ElyRunners/ElyRunners/media/" />
    

    Grtz

    L

  • AmandaEly 123 posts 379 karma points
    Apr 19, 2015 @ 13:34
    AmandaEly
    0

    Lennart,

    I was already on it but thatnk you so much for your support. I followed http://www.proworks.com/blog/2013/07/31/how-to-redirect-the-umbraco-media-path-to-another-location/ and I did also need a rootUrl, as that overload of PhysicalFilePath needs two arguments. I just set this to "/media/". I now have a fully functional test image. At least I haven't put it in a page yet but that is a detail!

Please Sign in or register to post replies

Write your reply to:

Draft