本文整理汇总了C#中Kooboo.CMS.Content.Models.MediaContent.GetRepository方法的典型用法代码示例。如果您正苦于以下问题:C# MediaContent.GetRepository方法的具体用法?C# MediaContent.GetRepository怎么用?C# MediaContent.GetRepository使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kooboo.CMS.Content.Models.MediaContent
的用法示例。
在下文中一共展示了MediaContent.GetRepository方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetContentStream
public byte[] GetContentStream(MediaContent content)
{
if (string.IsNullOrEmpty(content.GetRepository().Name))
{
var webClient = new WebClient();
return webClient.DownloadData(content.Url);
}
else
{
var mediaContentService = RemoteServiceFactory.CreateService<IMediaContentService>();
return mediaContentService.GetBytes(content.Repository, content.FolderName, content.FileName);
}
}
示例2: GetContentStream
public byte[] GetContentStream(MediaContent content)
{
var blobClient = CloudStorageAccountHelper.GetStorageAccount().CreateCloudBlobClient();
var path = string.Empty;
if (string.IsNullOrEmpty(content.GetRepository().Name))
{
path = content.VirtualPath.Substring(AzureBlobServiceSettings.Instance.Endpoint.Length);
//path = UrlUtility.Combine(path.Split('/').Select(it => StorageNamesEncoder.EncodeBlobName(it)).ToArray());
}
else
{
path = content.GetMediaBlobPath();
}
var contentBlob = blobClient.GetBlobReference(path);
byte[] data = null;
if (contentBlob.Exists())
{
data = contentBlob.DownloadByteArray();
}
return data;
}
示例3: GetContentStream
public Stream GetContentStream(MediaContent content)
{
var blobClient = CloudStorageAccountHelper.GetStorageAccount().CreateCloudBlobClient();
var path=string.Empty;
if(string.IsNullOrEmpty(content.GetRepository().Name))
{
path = content.VirtualPath.Substring(AzureBlobServiceSettings.Instance.Endpoint.Length);
}
else
{
path = content.GetMediaBlobPath();
}
var contentBlob = blobClient.GetBlobReference(path);
var stream = new MemoryStream();
if (contentBlob.Exists())
{
contentBlob.DownloadToStream(stream);
}
stream.Position = 0;
return stream;
}