asp.net mvc 4 - Azure blobs - cannot display image store in blob container in MVC 4 -
question background:
i have basic mvc 4 site , trying display picture stored in blob storage container in azure cloud account. store list of image uri's
in string list
, pass these view
should display
the issue:
i can't seem file name of image stored in container.
the following image shows container in azure. note there image stored in size of 101.28kb:
this code trying use retrieve blobs , read image uri's
:
azurestoragecontroller
pics
action method:
public actionresult pics() { var imagelist = new list<string>(); var imagesazure = new myblobstorageservice(); var container = imagesazure.getcloudblobcontainer(); foreach (var blobitem in container.listblobs()) { imagelist.add(blobitem.uri.tostring()); } return view(imagelist); }
the getcloudblobcontainer
method of myblobstorageservice
class:
public cloudblobcontainer getcloudblobcontainer() { string accountname = "fmfcpics"; string accountkey = "xxxxxx/yyyyyyyyy/3333333333=="; storagecredentials credentials = new storagecredentials(accountname, accountkey); cloudstorageaccount storageaccount = new cloudstorageaccount(credentials, true); cloudblobclient blobclient = storageaccount.createcloudblobclient(); cloudblobcontainer container = blobclient.getcontainerreference("images"); if (container.createifnotexists()) { container.setpermissions(new blobcontainerpermissions() { publicaccess = blobcontainerpublicaccesstype.blob }); } return container; }
the pics
view:
@{ viewbag.title = "pics"; } <h2>pics</h2> @foreach (var item in model) { <img src="@item" alt="picture" width="200" height="200" /> }
the uri in list being passed pics view is: https://fmfcpics.blob.core.windows.net/images/myblob not feature image file name.
any appreciated.
as guarav has stated already, thing check make sure container not "private".
Comments
Post a Comment