2
我需要幫助,我目前正在開發一個Umbraco api,它將從第三方網站以編程方式創建媒體。Umbraco媒體服務創建媒體
我使用以下命令來創建媒體
public HttpResponseMessage CreateMedia()
{
var mediaService = Services.MediaService;
using (WebClient client = new WebClient())
{
Stream s = client.OpenRead("http://karl.media.local/Uploads/ef093845-41dd-4620- b220-1b346a5f9b2e.jpg");
using (MemoryStream ms = new MemoryStream())
{
s.CopyTo(ms);
var mediaImage = mediaService.CreateMedia("test4", 1152, "Image");
mediaImage.SetValue("umbracoFile", "test4", ms);
mediaService.Save(mediaImage);
}
}
var response = Request.CreateResponse(HttpStatusCode.OK);
response.Content = new StringContent("ExternalMediaCreate", Encoding.UTF8, "application/json");
return response;
}
}
我在這一行mediaImage.SetValue得到以下錯誤( 「umbracoFile」, 「TEST4」,MS);:
<Error>
<Message>An error has occurred.</Message>
<ExceptionMessage>
Length cannot be less than zero. Parameter name: length
</ExceptionMessage>
</Error>
任何幫助,將不勝感激,
在此先感謝