How to get path of Media folder in orchard ?

Topics: Customizing Orchard
Nov 28, 2013 at 2:09 AM
Hi everyone,

i try adding image of product in Skywalker.Webshop module, but i can't save file to Media folder becauce i know which method can i get path of media folder ?.

somebody help me.
Nov 28, 2013 at 10:01 AM
look at the source code Orchard .I think you will find some useful things in module Orchard.MediaPicker or Orther

Nov 28, 2013 at 10:09 AM
Thank you leotran,

i try to it
Nov 29, 2013 at 5:10 AM
Why i don't find out Orchard.MediaPicker in version 1.7, I think i find out IMediaLibraryService of Orchard.MediaLibrary module which can upload with commands following:

var mediaPart = _mediaLibraryService.ImportMedia(file.InputStream, folderPath, filename);
// this is command in Orchard.MediaLibrary/Controllers/ClientStorageController

It doesn't work. the error is


How i can fix this error it ?

Thank you very much.
Nov 29, 2013 at 9:52 PM
As a test, does this also happen when you import media via the Media Library UI (Admin menu -> Media -> select some folder -> Import)?
Nov 29, 2013 at 11:43 PM
Edited Nov 29, 2013 at 11:50 PM
no, it doesn't.

that mean, i can import with media ui but i can't even use to

private readonly MediaService _mediaService;

var file = HttpContext.Current.Request.Files["Image"];
_var uploadStr = mediaService.UploadMediaFile('ProductImages', file.FileName, file.InputStream, false);
//ProductImages folder is /root/ProductImages
Nov 30, 2013 at 12:52 AM
Edited Nov 30, 2013 at 1:00 AM
i think my orchard had a error version when i set up orchard v.1.7.1 and Skywalker.Webshop module. I look at module.txt of Webshop module which requered orchard v.1.4, i don't know set up orchard v.1.4 because it haven't Solution file as v.1.7



even thought i used to code below, it still have error "execute query ..."
string path = HttpContext.Current.Server.MapPath("~/Media/ProductImages/" + file.FileName);