Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I have added Images in Umbraco Media using the code. Folder and Subfolder are created successfully and Images also...but Images are not showing in Admin panel.
Below is the code which i am using...help me if i am doing something wrong.
IMedia? _userProfilefolder = _mediaService.GetRootMedia().FirstOrDefault(m => m.Name.InvariantEquals("UserProfile"));
if (_userProfilefolder == null)
_userProfilefolder = _mediaService.CreateMediaWithIdentity("UserProfile", Constants.System.Root, MediaTypes.Folder);
IMedia? usernameFolder = _mediaService.GetPagedChildren(_userProfilefolder.Id, 0, int.MaxValue, out var folderCount)
.Where(x => x.ContentType.Alias == Constants.Conventions.MediaTypes.Folder)
.FirstOrDefault(c => c.Name.InvariantEquals(username));
if (usernameFolder == null)
usernameFolder = _mediaService.CreateMediaWithIdentity(username, _userProfilefolder.Id, MediaTypes.Folder);
await using (var ms = new MemoryStream())
var media = _mediaService.CreateMedia("ProfilePic2.jpg", usernameFolder.Id, Constants.Conventions.MediaTypes.Image);
media.SetValue(_mediaFileManager, _mediaUrlGenerators, _shortStringHelper, _contentTypeBaseServiceProvider, Constants.Conventions.Media.File, "ProfilePic2.jpg", ms);
Just to update everything is fine...but issue is that...I am storing the Media using the API, which is another application not the CMS application it self.
So i just want to know...how to setup the application URL and Media path in api application for CMS application.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted