I wrote some code so when an editor uploads an image different sizes of the uploaded image are created and save to a blob in aws, in the format epi.fx.blob://[provider]/[container]/[blob]]
While I can change the container portion, I am having problems figuring out how to change the blob portion of uri which is the image, to the image name plus the size it was changed to.
Any ideas on how to do this?
Ben, could you please share the code?
private void CreateImageInBlob(IContentMedia contentImage, string imageInfo, Stream resizedImages)
var imageBlobContainer = _imageFile.BinaryDataContainer.Scheme + "://default/" + _imageFileName; //blob container folder name
var blob = ServiceLocator.Current.GetInstance<IBlobFactory>().CreateBlob(new Uri(imageBlobContainer), Path.GetExtension(_imageFile.Name));
//some code to rename image blob from GUID to image name _ image size
blob.Write(resizedImages); //image blob is created
contentImage.BinaryData = blob;
Is this even possible? If not, what are your recomendation to get to simillar suitable solution.
I was just looking at the source code last week and the blob provider creates a new Guid.NewGuid() for the filename and it is not overwritable unfortunately. From their source
public static Uri NewBlobIdentifier(Uri container, string extension)
if (Path.GetExtension(extension) != extension)
throw new ArgumentException("Not a valid file extension", extension);
return new Uri(container, container.AbsolutePath + "/" + GuidToUriString(Guid.NewGuid()) + extension);
Yep, I notice that the NewBlobIdentifier function is called when writing to a newly created blob.
Since it was just on creation I was hoping that the name would be rewritable after, if there is no other imput I guess that is the answer, thanks.