Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more

Select media folder to save uploaded images in

Vote:
 

Hello!

I need to set a property on a page to allow the editor to select which asset folder uploaded images should be saved in. Right now, when a user submits an image in an form, I create a blob and just save it under SiteDefenition.Current.GlobalAssetRoot. How do I do this/change the place where I save the uploaded images?

#80681
Jan 29, 2014 13:01
Vote:
 

Hi, maybe this is not exactly what you want (asset folder), but you should be able to define the following property:

[Display(GroupName = SystemTabNames.Content, Order = 1)]
[Required]
[UIHint(UIHint.MediaFolder)]
public virtual ContentReference MyFolder { get; set; }

This will let you select a folder (only a folder) from the Edit interface, which you then can use for your file upload:

var repository = ServiceLocator.Current.GetInstance<IContentRepository>();
var file = contentRepository.GetDefault<GenericFile>(MyFolder);
...create blob, write and save file etc...

#80703
Jan 30, 2014 10:29
Vote:
 

That was exactly what I needed, thanks!

#80711
Jan 30, 2014 11:18
Vote:
 

Excellent, I was looking for this as well.

#131327
Jul 21, 2015 11:31
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.