i have code uploads images
var blobclient = _storageaccount.createcloudblobclient(); var container = blobclient.getcontainerreference(blobname); // create unique name images upload var file = string.format("{0}-{1}{2}", filename, guid.newguid(), path.getextension(filetoupload.filename)); // upload image blob storage var blockblob = container.getblockblobreference(file); blockblob.properties.contenttype = filetoupload.contenttype; await blockblob.uploadfromstreamasync(filetoupload.inputstream); fullpath = blockblob.uri.tostring();
now in blob have info name: test+guid / url: test+guid
how can save in blob name: test / url: guid , name in url not displayed?
it not work way have blob name different url. thing windows path resemble file name , these 2 cannot different.
but considering requirements, use guid in blob name , url actual name of file hidden url. , try use blob metadata storing , getting actual name.
// reference blob. cloudblob blob = blobclient.getblobreference("mycontainer/myblob.txt"); // populate blob's attributes. blob.fetchattributes(); // enumerate blob's metadata. foreach (var metadatakey in blob.metadata.keys) { console.writeline("metadata name: " + metadatakey.tostring()); console.writeline("metadata value: " + blob.metadata.get(metadatakey.tostring())); }
Comments
Post a Comment