从Episerver Blob文件获取图像的URL路径
我正在使用代码中的以下方法
添加到blob
Thumbnail = MediaToBlob(thumbMediaUrl, accessToken, ".jpg", blobFactory, qbankMedia, "text/html");
blobCache.Add(videoMediaUrl, qbankMedia.BinaryData);
mediatoblob方法
public Blob MediaToBlob(string mediaUrl, string accessToken, string extension, IBlobFactory blobFactory, IQBankEpiMedia qbankMedia, string mimeType, int maxLength = int.MaxValue)
{
var mediaStream = GetMediaStream(mediaUrl, accessToken, mimeType, maxLength);
Blob blob = null;
if (mediaStream != null)
{
blob = blobFactory.CreateBlob(qbankMedia.BinaryDataContainer, extension);
using (var blobStream = blob.OpenWrite())
{
byte[] buffer = new byte[64 * 1024];
int read;
while ((read = mediaStream.Read(buffer, 0, buffer.Length)) > 0)
blobStream.Write(buffer, 0, read);
mediaStream.Flush();
mediaStream.Close();
}
}
return blob;
}
我需要获得该缩略图对象的相对路径,以便我可以使用它,以便我可以使用它在现场渲染图像。 可以使用缩略图
epi.fx.blob://default/f791355aa6334c92b5f370c5cfafd971/adc882777a04431baae83a2e05f3f02d.jpg
。
http://localhost:8000/episerver/f791355aa6334c92b5f370c5cfafd971/adc882777a04431baae83a2e05f3f02d.jpg
我
I'm creating a blob file using the following method in my code
Adding to Blob
Thumbnail = MediaToBlob(thumbMediaUrl, accessToken, ".jpg", blobFactory, qbankMedia, "text/html");
blobCache.Add(videoMediaUrl, qbankMedia.BinaryData);
MediaToBlob Method
public Blob MediaToBlob(string mediaUrl, string accessToken, string extension, IBlobFactory blobFactory, IQBankEpiMedia qbankMedia, string mimeType, int maxLength = int.MaxValue)
{
var mediaStream = GetMediaStream(mediaUrl, accessToken, mimeType, maxLength);
Blob blob = null;
if (mediaStream != null)
{
blob = blobFactory.CreateBlob(qbankMedia.BinaryDataContainer, extension);
using (var blobStream = blob.OpenWrite())
{
byte[] buffer = new byte[64 * 1024];
int read;
while ((read = mediaStream.Read(buffer, 0, buffer.Length)) > 0)
blobStream.Write(buffer, 0, read);
mediaStream.Flush();
mediaStream.Close();
}
}
return blob;
}
I Need to get a relative path to this Thumbnail object so that I can use it to render the image in site. I can use Thumbnail.ID.AbsoluteUri to get this :
epi.fx.blob://default/f791355aa6334c92b5f370c5cfafd971/adc882777a04431baae83a2e05f3f02d.jpg
instead of that, i need something like this:
http://localhost:8000/episerver/f791355aa6334c92b5f370c5cfafd971/adc882777a04431baae83a2e05f3f02d.jpg
Can anyone guide me to have something that I can use as normal Url for images?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以通过将属性名称附加到URL来访问缩略图属性:
这适用于您的内容类型可能具有的任何缩略图属性。 “缩略图”是ImageData上可用的默认propety。
You can access thumbnail properties by appending the property name to the URL:
This works for any thumbnail property your content type might have. 'Thumbnail' is the default propety available on ImageData.
当您将图像或媒体文件加载到Episerver中时,它将被视为内容,它将具有内容参考,因此,您还可以使用它来获得资产。因此,将文件保存到斑点时,您应该使用它来保存媒体内容。然后,您可以像情节中的任何内容一样获取URL。
I would recomend checking these two blog post by Jon
如何获取episerver中图像的URL
When you load an image or a media file into Episerver, it will be treated as content, it will have a content reference and consequently, you will also be able to get assets using it. So when saving a file to the blob you should then use that to save the media content. You can then get the url like you do to any content in episerver.
I would recomend checking these two blog post by Jon
How to upload an image into episerver cms via code
How to get the url for an image in episerver