Hey, i am currently trying to upload an image as a File Media type and i get this error... This code works well for files that arent images and when i upload an image as a Media Type Image it works fine.
Error is "No PropertyType exists with the supplied alias: umbracoWidth" i get this at the result.SetValue line.
IMedia result = Services.MediaService.CreateMedia(fileName, sharedContentNode.Id, importedData.ContentType.ToString());
if (importedData.ContentType.ToString() == "Image" || importedData.ContentType.ToString() == "File")
{
JArray j = new JArray(importedData.Properties);
var umbracoFile = j.First(x => x["Alias"].Value<string>() == "umbracoFile");
if (umbracoFile != null) {
string fileValue = umbracoFile["Value"].ToString();
if (!string.IsNullOrEmpty(fileValue)) {
mediaFullPath = "C:/PTC/medias/" + fileValue;
var file = new FileInfo(mediaFullPath);
using (var fs = file.OpenRead())
{
result.SetValue("umbracoFile", file.Name, fs);
Services.MediaService.Save(result);
}
}
}
}
I have no idea why its throwing that error, but I find it strange that you are doing this Services.MediaService.CreateMedia(fileName, sharedContentNode.Id, importedData.ContentType.ToString()) when you want to save to a file type even if it's an image (if i understand your explenation correctly). Why not do Services.MediaService.CreateMedia(fileName, sharedContentNode.Id, "File")
Same problem here (Umbraco 7.5.12). I'm using the "File" media type but it's trying and failing to set umbracoWidth when the user uploads an image file.
Uploading Image as File
Hey, i am currently trying to upload an image as a File Media type and i get this error... This code works well for files that arent images and when i upload an image as a Media Type Image it works fine.
Error is "No PropertyType exists with the supplied alias: umbracoWidth" i get this at the result.SetValue line.
Thanks for the help !
Hey Mathieu
I have no idea why its throwing that error, but I find it strange that you are doing this
Services.MediaService.CreateMedia(fileName, sharedContentNode.Id, importedData.ContentType.ToString())
when you want to save to a file type even if it's an image (if i understand your explenation correctly). Why not doServices.MediaService.CreateMedia(fileName, sharedContentNode.Id, "File")
Hi Mathieu,
How have you solved this issue, please?
Thanks
Kind Regards
Same problem here (Umbraco 7.5.12). I'm using the "File" media type but it's trying and failing to set umbracoWidth when the user uploads an image file.
Did anyone figure this out?
Edit: I've logged a bug.
is working on a reply...