c# - Azure Storage private container blob to MemoryStream -
i'm running around in circles trying work out code download file azure storage private container memorystream.
i have far...
storagecredentials storagecredentials = new storagecredentials(*my storageaccountname*, *my storageaccountaccesskey*); cloudstorageaccount storageaccount = new cloudstorageaccount(storagecredentials, true); uri bloburi = new uri(featurefile.url); cloudblockblob blob = new cloudblockblob(bloburi); memorystream mem = new memorystream(); blob.downloadtostream(mem);
it errors on last line with...
the remote server returned error: (404) not found.
however, work without error when container not private.
any appreciated, thank you.
please try following code:
storagecredentials storagecredentials = new storagecredentials(*my storageaccountname*, *my storageaccountaccesskey*); cloudstorageaccount storageaccount = new cloudstorageaccount(storagecredentials, true); uri bloburi = new uri(featurefile.url); cloudblockblob blob = new cloudblockblob(bloburi, storagecredentials);//added storagecredentials memorystream mem = new memorystream(); blob.downloadtostream(mem);
since container has private
acl, request needs authenticated. using this
constructor of cloudblockblob
takes care of that.
Comments
Post a Comment