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

Popular posts from this blog

c# - How can I have the VS Debugger break in the correct location for exceptions thrown in Async methods in a Console App? -

php - Issues outputting data after prepared statement with loops -

javascript - How to pass a property by reference -