trying to upoad image from disk to umbraco (v6.1.5) using mediaService.CreateMedia
Hi
trying to upoad image from disk to umbraco (v6.1.5) using mediaService.CreateMedia. Using mediaService.CreateMedia I can create the media object in umbraco which can be viewed from admin.
Problem I am having is getting the actual image uploaded to umbraco.
Tried
var media = mediaService.CreateMedia("xxxx", 2553, "Image");
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: The best overloaded meth d match for 'Umbraco.Core.Models.ContentBase.SetPropertyValue(string, string)' as some invalid arguments at CallSite.Target(Closure , CallSite , Object , String , Object )
trying to upoad image from disk to umbraco (v6.1.5) using mediaService.CreateMedia
Hi
trying to upoad image from disk to umbraco (v6.1.5) using mediaService.CreateMedia. Using mediaService.CreateMedia I can create the media object in umbraco which can be viewed from admin.
Problem I am having is getting the actual image uploaded to umbraco.
Tried
var media = mediaService.CreateMedia("xxxx", 2553, "Image");
string fileLocation = "C:\\location\\imagename.jpg";
byte[] newImage = null;
newImage = File.ReadAllBytes(fileLocation);
media.SetValue("umbracoFile", newImage );
mediaService.Save(media);
but throws error
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: The best overloaded meth
d match for 'Umbraco.Core.Models.ContentBase.SetPropertyValue(string, string)'
as some invalid arguments
at CallSite.Target(Closure , CallSite , Object , String , Object )
Has anyone used this api for this?
Update:- Got a solution from http://our.umbraco.org/forum/developers/api-questions/38533-How-do-you-SaveUpload-a-file-to-Media-using-the-new-MediaService-API?p=0#comment139687 which works from a web app but still getting error in console app if get it working will update post with fix.
Update:- Got console app working following from http://www.wiliam.com.au/wiliam-blog/web-design-sydney-umbraco-6-and-the-servicecontext.
A MemoryStream and File.ReadAllBytes was my key to success. Tried ALL other .NETfx options :)
is working on a reply...