November Happy Hour will be moved to Thursday December 5th.
AI OnAI Off
November Happy Hour will be moved to Thursday December 5th.
Hope this helps:
if (media != null)
{
using (var stream = media.BinaryData.OpenRead())
{
long sizeInBites = stream.Length;
}
}
Hi, Is this the official way to go, to obtain the file size, seems like an overhead creating a stream just for the size.
I am a bit worried about the performance impact when dealing with larger amounts of files.
/Daniel
Hey, Daniel,
You might consider a property Size (with ScaffoldColumn(false)) on the ImageFile that is filled once when image is created. That way, you just read the size, but you set it only once.
Hi Marija thank you for your suggestion, I was thinking about doing as you suggested but I am a bit lazy and expected this to be a built in feature in MediaData class.
/D
I use the following code to retrieve my media file, but do not know how to get the file size of the requested file
var contentRepository = ServiceLocator.Current.GetInstance<IContentRepository>();
var contentLink = new ContentReference(57);
var media = contentRepository.Get<MediaFile>(contentLink);
Can anyone help