Errors Saving an Image from byte[] (from SQL Server)
Hi all,
I do hope someone can supply me with a nice quick and consise answer to my issue...
In a nutshell, I'm getting the error :
An exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dll but was not handled in user code
Additional information: startIndex cannot be larger than length of string.
within this function on the SetValue line :
private bool CacheImage(byte[] bytes, string filename){
//get the Media Service and create the node
IMediaService _mediaService = ApplicationContext.Current.Services.MediaService;
IMedia _mediaItem = _mediaService.CreateMedia(filename, 1159, "Image");
//load the bytes as a stream and apply to the node
MemoryStream mStream = new MemoryStream(bytes);
mStream.Position = 0;
_mediaItem.SetValue("umbracoFile", filename, mStream);
//save the media node
_mediaService.Save(_mediaItem);
return true;
}
I've seen a bunch of posts about similar problems but nothing seems to supply me with a 100% solution. Can anyone give me a hint?
One question that springs to mind is 'what string'? we're dealing with a stream here right??
It's not a problem with the stream, but the filename (2nd parameter). It requires the extension on the filename (of course) but the saved filename I was using was devoid of it!
Errors Saving an Image from byte[] (from SQL Server)
Hi all,
I do hope someone can supply me with a nice quick and consise answer to my issue...
In a nutshell, I'm getting the error :
within this function on the SetValue line :
I've seen a bunch of posts about similar problems but nothing seems to supply me with a 100% solution. Can anyone give me a hint?
One question that springs to mind is 'what string'? we're dealing with a stream here right??
Thanks in advance
Danny "Blatant"
Nevermind, clue is in the error...
It's not a problem with the stream, but the filename (2nd parameter). It requires the extension on the filename (of course) but the saved filename I was using was devoid of it!
is working on a reply...