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
Hi all,
problably I'm missing something... I'm trying to create some medias (images) but properties (size, height, and so on) don't update. Only the file is correct.Here's the code.Thanks in advance
var mediaName = sender.getProperty("name").Value + " " + String.Format("{0:d-M-yyyy HHmmss}", DateTime.Now); var media = Media.MakeNew(mediaName, MediaType.GetByAlias("image"), umbraco.BasePages.UmbracoEnsuredPage.CurrentUser, Convert.ToInt32(ConfigurationManager.AppSettings.Get("GrabzItMediaFolder"))); string storagePath = ConfigurationManager.AppSettings.Get("MediaRootPath") + media.Id.ToString(); System.IO.Directory.CreateDirectory(storagePath); string fullFilePath = storagePath + "\\" + mediaName + ".jpeg"; media.getProperty("umbracoExtension").Value = "jpeg"; Bitmap img = (Bitmap)Image.FromFile(temporaryPath, true); img.Save(fullFilePath, ImageFormat.Jpeg); media.getProperty("umbracoHeight").Value = img.Height.ToString(); media.getProperty("umbracoWidth").Value = img.Width.ToString(); media.getProperty("umbracoBytes").Value = new FileInfo(fullFilePath).Length; media.getProperty("umbracoFile").Value = fullFilePath; media.XmlGenerate(new XmlDocument()); media.Save(); sender.getProperty("screenshot").Value = media.Id; img.Dispose(); File.Delete(temporaryPath);
I just found this help doc: http://our.umbraco.org/Documentation/Reference/Management-v6/Models/Media
I would try the new MediaService and then do .SetValue(string propertyTypeAlias, object value)
Unfortunatly I'm working on umbraco 4.11 and that's for 6.x
Thank you anyway :)
You may have already reviewed this post but if not it may help: http://our.umbraco.org/forum/developers/api-questions/3477-Creating-Media-Programatically?p=1
Thanks for your reply, I'm working on this project in my spare time, I will check that solution asap :)
Just wondering if you solved this Alex, as I'm having the same issue - umbracoFile is the only one that looks to work for me.
Unfortunatly no.This one is a personal hobby project and I'm not currently working on it. I will publish some news if I will manage to solve this issue
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Creating media programmaticaly, properties update
Hi all,
problably I'm missing something... I'm trying to create some medias (images) but properties (size, height, and so on) don't update. Only the file is correct.
Here's the code.
Thanks in advance
I just found this help doc: http://our.umbraco.org/Documentation/Reference/Management-v6/Models/Media
I would try the new MediaService and then do .SetValue(string propertyTypeAlias, object value)
Unfortunatly I'm working on umbraco 4.11 and that's for 6.x
Thank you anyway :)
You may have already reviewed this post but if not it may help: http://our.umbraco.org/forum/developers/api-questions/3477-Creating-Media-Programatically?p=1
Thanks for your reply, I'm working on this project in my spare time, I will check that solution asap :)
Just wondering if you solved this Alex, as I'm having the same issue - umbracoFile is the only one that looks to work for me.
Unfortunatly no.
This one is a personal hobby project and I'm not currently working on it. I will publish some news if I will manage to solve this issue
is working on a reply...