通过ashx获取azure BLOB图像 [英] Get azure BLOB image through ashx

查看:150
本文介绍了通过ashx获取azure BLOB图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将云网站,SQL DB,BLOB......设置为azure。

这是我想要做的事情:

通过ashx文件从BLOB(azure)获取图像并在网页中显示图像(元素:图像)。



它找不到任何照片和节目错误:

错误代码>>>

无法加载资源:服务器响应状态为500(内部服务器错误)



ashx代码>>>

CloudStorageAccount存储= CloudStorageAccount.Parse(string.Format(DefaultEndpointsProtocol = https; AccountName = {0}; AccountKey = {1},storageName,storageKey));

CloudBlobClient cloudBlobClient = storage.CreateCloudBlobClient();



CloudBlobContainer container = cloudBlobClient.GetContainerReference(memid+ MemID);

容器。 CreateIfNotExist();



CloudBlob obj = container.GetBlobReference(PhotoHash);

BlobStream blobstream = obj.OpenRead();

图片img = null;

img = Image.FromStream(blobstream,true);



context.Response.ContentType =image / jpeg;

var byteArray = obj.DownloadByteArray();

context.Response.OutputStream.Write(byteArray,0,byteArray.Length);



aspx代码>>>

var PldImg = $(''< img>< / img>'')

.attr(''src'',''LoadFriendsPhoto / LoadPhotoFromBlob.ashx?MemID =''+ MemID +''& PathNameData =''+ friInfo [i - 1] .PhotoHash) ;



ps PhotoHash是BLOB文件名,例如:004dae3947219415f5899b2d6bbe9637

我该如何解决这个问题?

谢谢。

I set "cloud web site", "SQL DB", "BLOB"... onto azure.
Here is the thing I want to do:
Get image from BLOB(azure) through ashx file and show out the image in web page (element:image).

It can''t find any photo and show error:
Error code>>>
Failed to load resource: the server responded with a status of 500 (Internal Server Error)

ashx code>>>
CloudStorageAccount storage = CloudStorageAccount.Parse(string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}", storageName, storageKey));
CloudBlobClient cloudBlobClient = storage.CreateCloudBlobClient();

CloudBlobContainer container = cloudBlobClient.GetContainerReference("memid" + MemID);
container.CreateIfNotExist();

CloudBlob obj = container.GetBlobReference(PhotoHash);
BlobStream blobstream = obj.OpenRead();
Image img = null;
img = Image.FromStream(blobstream, true);

context.Response.ContentType = "image/jpeg";
var byteArray = obj.DownloadByteArray();
context.Response.OutputStream.Write(byteArray, 0, byteArray.Length);

aspx code>>>
var PldImg = $(''<img></img>'')
.attr(''src'', ''LoadFriendsPhoto/LoadPhotoFromBlob.ashx?MemID='' + MemID + ''&PathNameData='' + friInfo[i - 1].PhotoHash);

p.s PhotoHash is the BLOB file name, example: 004dae3947219415f5899b2d6bbe9637
How can I fix this?
Thanks.

推荐答案

(''< img>< / img>'')

.attr(''src'' ,''LoadFriendsPhoto / LoadPhotoFromBlob.ashx?MemID =''+ MemID +''& PathNameData =''+ friInfo [i - 1] .PhotoHash);



ps PhotoHash是BLOB文件名,例如:004dae3947219415f5899b2d6bbe9637

如何解决这个问题?

谢谢。
(''<img></img>'')
.attr(''src'', ''LoadFriendsPhoto/LoadPhotoFromBlob.ashx?MemID='' + MemID + ''&PathNameData='' + friInfo[i - 1].PhotoHash);

p.s PhotoHash is the BLOB file name, example: 004dae3947219415f5899b2d6bbe9637
How can I fix this?
Thanks.


我'我已经修好了。只需使用''url''就可以解决它。

谢谢。
I''ve fixed this. Just use ''url'' can solve it.
Thanks.


这篇关于通过ashx获取azure BLOB图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆