AI OnAI Off
Hi, Jaanna,
Browser caches based on the URL, so when uploading a new image, you need to change the URL segment if you want hint the browser that the image has changed.
So, you could either name the image based on a date and then clear the URL segment (so that Epi automatically generates it for you) or you could just set the URL segment (but then you need to think of special characters yourself.
I do the first thing, but you will need to adjust this code to match your variable names:
var filename = string.Format("{0}{1}", DateTime.Now.ToString("yyyy-MM-dd_HHmm"), Path.GetExtension(file.FileName)); epiImageFile.Name = filename; epiImageFile.RouteSegment = null;
BR,
Marija
Yes, "renaming" the URL segment rather (as a consequence of renaming the Media and setting the segment to null).
// In case the URL for the image isn't important, which is seldom the case for images.
Hi
I programatically upload an image . I can see that image in the asset pane at the CMS admin .But when i browse the page , it always showing the previous image after replace the image
my code is
if (userProfileImage != null)(userProfileImage.ContentLink).CreateWritableClone();;
{
newImage = (ImageFile)contentRepository.Get
}
else{
newImage = contentRepository.GetDefault(folder.ContentLink);
newImage.Name = userIfo.FirstName;
}
var byteArrayData = imageService.ToByteArray(image); ;
var blob = blobFactory.CreateBlob(newImage.BinaryDataContainer, extention);
using (var s = blob.OpenWrite())
{
var w = new StreamWriter(s);
w.BaseStream.Write(byteArrayData, 0, byteArrayData.Length);
w.Flush();
}
newImage.BinaryData = blob;
var imageContentRef = contentRepository.Save(newImage, SaveAction.Publish, AccessLevel.NoAccess);
Thanks in advance