public ActionResult Create() { if (!Services.Authorizer.Authorize(Permissions.ManageOwnMedia, T("Couldn't create media folder"))) { return(new HttpUnauthorizedResult()); } var viewModel = new MediaManagerFolderCreateViewModel(); UpdateModel(viewModel); if (!_mediaLibraryService.CanManageMediaFolder(viewModel.FolderPath)) { return(new HttpUnauthorizedResult()); } try { _mediaLibraryService.CreateFolder(viewModel.FolderPath, viewModel.Name); Services.Notifier.Information(T("Media folder created")); } catch (ArgumentException argumentException) { Services.Notifier.Error(T("Creating Folder failed: {0}", argumentException.Message)); Services.TransactionManager.Cancel(); return(View(viewModel)); } return(RedirectToAction("Index", "Admin", new { area = "Tomelt.MediaLibrary" })); }
protected string GetThumbnailFolder(string mediaPath) { // Creates a thumbnail folder if doesn't exists if (!_mediaService.GetMediaFolders(mediaPath).Select(o => o.Name).Contains(ThumbnailFolder)) { _mediaService.CreateFolder(mediaPath, ThumbnailFolder); } return(_storageProvider.Combine(mediaPath, ThumbnailFolder)); }
//TODO: Remove Image repository as soon as it can cascade the saving public ImageGalleryService(IMediaLibraryService mediaService, IRepository<ImageGallerySettingsRecord> repository, IRepository<ImageGalleryImageSettingsRecord> imageRepository, IThumbnailService thumbnailService, IRepository<ImageGalleryRecord> imageGalleryPartRepository, IOrchardServices services, IStorageProvider storageProvider) { _storageProvider = storageProvider; _services = services; _imageGalleryPartRepository = imageGalleryPartRepository; _repository = repository; _mediaService = mediaService; _imageRepository = imageRepository; _thumbnailService = thumbnailService; if (_mediaService.GetMediaFolders(string.Empty).All(o => o.Name != ImageGalleriesMediaFolder)) { _mediaService.CreateFolder(string.Empty, ImageGalleriesMediaFolder); } }
//TODO: Remove Image repository as soon as it can cascade the saving public ImageGalleryService(IMediaLibraryService mediaService, IRepository <ImageGallerySettingsRecord> repository, IRepository <ImageGalleryImageSettingsRecord> imageRepository, IThumbnailService thumbnailService, IRepository <ImageGalleryRecord> imageGalleryPartRepository, IOrchardServices services, IStorageProvider storageProvider) { _storageProvider = storageProvider; _services = services; _imageGalleryPartRepository = imageGalleryPartRepository; _repository = repository; _mediaService = mediaService; _imageRepository = imageRepository; _thumbnailService = thumbnailService; if (_mediaService.GetMediaFolders(string.Empty).All(o => o.Name != ImageGalleriesMediaFolder)) { _mediaService.CreateFolder(string.Empty, ImageGalleriesMediaFolder); } }
public ActionResult Create() { if (!Services.Authorizer.Authorize(Permissions.ManageOwnMedia)) { Services.Notifier.Error(T("Couldn't create media folder")); return(new HttpUnauthorizedResult()); } var viewModel = new MediaManagerFolderCreateViewModel(); UpdateModel(viewModel); if (!(_mediaLibraryService.CheckMediaFolderPermission(Permissions.ImportMediaContent, viewModel.FolderPath) || _mediaLibraryService.CheckMediaFolderPermission(Permissions.EditMediaContent, viewModel.FolderPath))) { return(new HttpUnauthorizedResult()); } try { bool valid = String.IsNullOrWhiteSpace(viewModel.Name) || Regex.IsMatch(viewModel.Name, @"^[^:?#\[\]@!$&'()*+,.;=\s\""\<\>\\\|%]+$"); if (!valid) { throw new ArgumentException(T("Folder contains invalid characters").ToString()); } else { _mediaLibraryService.CreateFolder(viewModel.FolderPath, viewModel.Name); Services.Notifier.Information(T("Media folder created")); } } catch (ArgumentException argumentException) { Services.Notifier.Error(T("Creating Folder failed: {0}", argumentException.Message)); Services.TransactionManager.Cancel(); return(View(viewModel)); } return(RedirectToAction("Index", "Admin", new { area = "Orchard.MediaLibrary" })); }
public async Task <ActionResult <MediaFolder> > CreateFolder([FromQuery] string folderName, [FromQuery] string parentFolderId) { return(Ok(await _mediaLibraryService.CreateFolder(folderName, parentFolderId))); }
public void CreateImageGallery(string name) { _mediaService.CreateFolder(ImageGalleriesMediaFolder, name); }