No overload for method 'SetValue' takes '3' arguments
I'm trying to upload a file to the media archive but when i dont hardcode the parentnode in my SetValue i get this error "No overload for method 'SetValue' takes '3' arguments"
This gives me the error
System.Web.HttpFileCollectionBase files = Request.Files;
string[] fieldNames = files.AllKeys;
for (int i = 0; i < fieldNames.Length; ++i)
{
string field = fieldNames[i];
if(field == "kontraktfile" && Request.Files[i].ContentLength > 0){
var kontrakt = _mediaService.CreateMedia(Request.Files[i].FileName, Umbraco.Media(1263).Id, "File");
s = Request.Files[i].InputStream;
kontrakt.SetValue("umbracoFile", Request.Files[i].FileName, s);
s.Close();
_mediaService.Save(kontrakt);
}
This does not
System.Web.HttpFileCollectionBase files = Request.Files;
string[] fieldNames = files.AllKeys;
for (int i = 0; i < fieldNames.Length; ++i)
{
string field = fieldNames[i];
if(field == "kontraktfile" && Request.Files[i].ContentLength > 0){
var kontrakt = _mediaService.CreateMedia(Request.Files[i].FileName, 1263, "File");
s = Request.Files[i].InputStream;
kontrakt.SetValue("umbracoFile", Request.Files[i].FileName, s);
s.Close();
_mediaService.Save(kontrakt);
}
So i dont really understand why Umbraco.Media(1263).Id and 1263 isnt identical. This is on Umbraco 7.10.4.
// get the media item assigned in content
var mediaItem = Model.Content.GetPropertyValue<IPublishedContent>("mediaMappe");
// get first chidl folder
var firstChildFolder = mediaItem.Childeren().First();
Then you can use firstChildFolder.Id as the id you pass in when you create the media item.
No overload for method 'SetValue' takes '3' arguments
I'm trying to upload a file to the media archive but when i dont hardcode the parentnode in my SetValue i get this error "No overload for method 'SetValue' takes '3' arguments"
This gives me the error
This does not
So i dont really understand why Umbraco.Media(1263).Id and 1263 isnt identical. This is on Umbraco 7.10.4.
WHen you do Umbraco.Media(1263) you will get a dynamic object representing your media item.
But the method CreateMedia needs only the integer id.
Dave
Hello Dave
Doesnt work either. how can i set the ParentId as an integer without hardcoding it?
is what i want to do for the ParentId.
Hi Simon,
So if understand correctly "mediaMappe" is media picker property on your doctype ? What did the user select there ? A folder ?
Dave
Hi Dave
Yes Its a media picker where i've selected a folder. the first child of that folder is also a folder.
Hi Simon,
I think you need the following code :
Then you can use firstChildFolder.Id as the id you pass in when you create the media item.
Dave
That worked. Thanks.
is working on a reply...