Saturday 15 June 2013

javascript - Set Azure Metadata on BlockBlob via REST API -



javascript - Set Azure Metadata on BlockBlob via REST API -

i want set custom metadata property on blob on azure using azure rest api. upload of file works ok (also done via rest api). set custom metadata followed these instructions. sample url be:

(put method) https://myaccount.blob.core.windows.net/ph0wzj1k4dbuwfusyqw38z2jgfk5p56bfnlj5/a5bc77a8d4d34edeb6d3212fc6bbd8a9.jpg?sv=2014-02-14&sr=c&si=blobcontainer&sig=somesignaturecomp=metadata

with request header:

x-ms-meta-logicalname:20141028_064011.jpg

whether run url via jquery ajax or thru fiddler same result: phone call seems successful (i 200 status code) if inspect blob metadata (using c# code) key not found , metadata empty.

instead, if c#, can set , metadata on blob wish.

sample c# code (now working):

var blobs = container.listblobs(null, true, bloblistingdetails.metadata).cast<cloudblockblob>(); foreach (var blob in blobs) { console.writeline(blob.metadata["logicalname"]); }

as can see have entered shared access signature in url , not in request headers instructions show, uncertainty problem because on uploading , other operations (also on table storage) works fine.

am doing wrong? (obviously yes, what?... :) )

solved:

investigating azure storage explorer saw metadata correctly set , there, not retrieved via c#. thanx gaurav's suggestion have edited c# code sample had posted , retrieving metadata had set via rest api.

the metadata there you're not able see because haven't fetched it. alter listblobs() call. assuming you're using latest version of storage client library, can like:

var blobs = container.listblobs(null, true, bloblistingdetails.metadata).cast<cloudblockblob>();

this populate metadata along other properties.

javascript rest azure

No comments:

Post a Comment