Hi guys, trying to upload some media using the _mediaService in a custom UmbracoForms workflow but don't appear to be doing it right. (Umbraco 8.6.1, Forms 8.4.1)
FileInfo fi = new FileInfo(file);
// Initialize a new image at the root of the media archive
IMedia media = _mediaService.CreateMedia(Path.GetFileNameWithoutExtension(fi.Name), Umbraco.Core.Constants.System.Root, Umbraco.Core.Constants.Conventions.MediaTypes.Image);
// Set the property value (Umbraco will handle the underlying magic)
media.SetValue(Umbraco.Core.Composing.Current.Services.ContentTypeBaseServices, Umbraco.Core.Constants.Conventions.Media.File, fi.Name, stream);
// Save the media
_mediaService.Save(media);
However this doesn't work as the SetValue method does accept these arguments and so therefore errors.
Issue saving new media using MediaService
Hi guys, trying to upload some media using the _mediaService in a custom UmbracoForms workflow but don't appear to be doing it right. (Umbraco 8.6.1, Forms 8.4.1)
However this doesn't work as the SetValue method does accept these arguments and so therefore errors.
I followed the documentation here
https://our.umbraco.com/Documentation/Reference/Management/Services/MediaService/Index/
Am I doing something wrong?
Hi,
Have you added 'using Umbraco.Core' to the top of your file? The extension used there is stored in that namespace.
-Joep
@Joep sorry I forgot to update this issue.
You're absolutely right though that is exactly what I had missed from the documentation (should have read more carefully).
Thank you for your help anyway :)
is working on a reply...