I cant find any working solution to upload local files to Umbraco programmatically.
Tried this:
uFile = mediaService.CreateMedia(fileName, parentId, mediaType);
var streamFile = new FileStream(localFile, FileMode.Open);
uFile.SetValue(Constants.Conventions.Media.File, streamFile);
streamFile.Close();
mediaService.Save(uFile);
Error on uFile.SetValue():
An unhandled exception of type
'Microsoft.CSharp.RuntimeBinder.RuntimeBinderException' occurred in
System.Core.dll
Additional information: The best overloaded method match for
'Umbraco.Core.Models.ContentBase.SetPropertyValue(string, string)' has
some invalid arguments
Upload local files to Media programmatically
Hi
I cant find any working solution to upload local files to Umbraco programmatically.
Tried this:
Error on uFile.SetValue():
Local file exists.
Any help?
Finally found the answer:
Add:
Now we have more options to SetValue()
Yey!
But, that didn't work.
The files are listed in BackOffice, but they are not physical on the server (my machine).
I am running a Console Application in another project, to create pages, upload files and set content.
What more should I do? Copy files to Web project Media-folder? Doesn't feel like the best practice here.
is working on a reply...