gpt4 book ai didi

image - 如果我将图像存储在我的 blob 中,如何将 html 的 标签与 blob uri 绑定(bind)以在 ui 上显示图像?

转载 作者:行者123 更新时间:2023-12-03 00:51:32 24 4
gpt4 key购买 nike

我将图像存储在 azure blob 中,并且想在 UI 上显示图像,但我想将我的 img 标签与 blob uri 绑定(bind)。如何将 html 的 标签与 blob uri 绑定(bind)以在 UI 上显示图像?

这是我的 Controller ...

public class HomeController : Controller
{

public ActionResult Index()
{
ViewBag.path = @"F:\download_button_small2.png";
return View();
}

public FileContentResult myAction(string path)
{
string fileName = Path.GetFileNameWithoutExtension(path);
byte[] imageInBytes = System.IO.File.ReadAllBytes(path);
//upload image to blob and URL in table
ImageContainer img = new ImageContainer();
string imageUri = img.insert(fileName, imageInBytes);
//returns back the image uri from Blob Storage
return new FileContentResult(imageInBytes, "image/png");
}
}

这是我的索引:

我正在尝试注释部分,即寻找将 uri 传递到 img 标签的方法...但没有得到任何位置...所以请帮忙,我必须在 Controller 中进行哪些更改以及在我的索引中以获得所需的结果。

最佳答案

如果您已将图像保存在 blobstorage 中,则可以从

访问它
http://<storage-account-name>.blob.core.windows.net/<container-name>/<blob-name>  

修改您的操作方法以返回以该 URL 作为其值的字符串。

此外,请确保您的存储帐户设置为公共(public)访问。

有关使用 Azure Blob 存储的更多详细信息,请参阅以下内容:

Get started with Azure Blob storage using .NET

Azure Bits #2 – Saving The Image To Azure Blob Storage

关于image - 如果我将图像存储在我的 blob 中,如何将 html 的 <img> 标签与 blob uri 绑定(bind)以在 ui 上显示图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35284658/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com