本文整理汇总了C#中Kooboo.CMS.Content.Models.MediaContent.GetMediaBlobPath方法的典型用法代码示例。如果您正苦于以下问题:C# MediaContent.GetMediaBlobPath方法的具体用法?C# MediaContent.GetMediaBlobPath怎么用?C# MediaContent.GetMediaBlobPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kooboo.CMS.Content.Models.MediaContent
的用法示例。
在下文中一共展示了MediaContent.GetMediaBlobPath方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Delete
public void Delete(MediaContent content)
{
var blobClient = CloudStorageAccountHelper.GetStorageAccount().CreateCloudBlobClient();
var contentBlob = blobClient.GetBlobReference(content.GetMediaBlobPath());
contentBlob.DeleteIfExists();
}
示例2: Add
public void Add(MediaContent content, bool overrided)
{
if (content.ContentFile != null)
{
content.FileName = content.ContentFile.FileName;
content.UserKey = content.FileName;
content.UUID = content.FileName;
var blobClient = CloudStorageAccountHelper.GetStorageAccount().CreateCloudBlobClient();
var contentBlob = blobClient.GetBlobReference(content.GetMediaBlobPath());
contentBlob = content.MediaContentToBlob(contentBlob);
contentBlob.UploadFromStream(content.ContentFile.Stream);
content.VirtualPath = contentBlob.Uri.ToString();
}
}
示例3: Update
public void Update(MediaContent @new, MediaContent old)
{
if ([email protected](old.FileName, StringComparison.OrdinalIgnoreCase))
{
MoveContent(old, @new);
}
var blobClient = CloudStorageAccountHelper.GetStorageAccount().CreateCloudBlobClient();
var contentBlob = blobClient.GetBlobReference(@new.GetMediaBlobPath());
contentBlob = @new.MediaContentToBlob(contentBlob);
contentBlob.SetMetadata();
@new.VirtualPath = contentBlob.Uri.ToString();
}
示例4: MoveContent
private static void MoveContent(MediaContent oldMediaContent, MediaContent newMediaContent)
{
var blobClient = CloudStorageAccountHelper.GetStorageAccount().CreateCloudBlobClient();
var oldContentBlob = blobClient.GetBlobReference(oldMediaContent.GetMediaBlobPath());
var newContentBlob = blobClient.GetBlobReference(newMediaContent.GetMediaBlobPath());
newContentBlob.CopyFromBlob(oldContentBlob);
oldContentBlob.DeleteIfExists();
}
示例5: SaveContentStream
public void SaveContentStream(MediaContent content, Stream stream)
{
if (stream.Length == 0)
{
return;
}
var blobClient = CloudStorageAccountHelper.GetStorageAccount().CreateCloudBlobClient();
var contentBlob = blobClient.GetBlobReference(content.GetMediaBlobPath());
if (contentBlob.Exists())
{
contentBlob.UploadFromStream(stream);
}
}
示例6: 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;
}
示例7: MoveContent
private static void MoveContent(MediaContent oldMediaContent, MediaContent newMediaContent)
{
var blobClient = CloudStorageAccountHelper.GetStorageAccount().CreateCloudBlobClient();
var oldContentBlob = blobClient.GetBlockBlobReference(oldMediaContent.GetMediaBlobPath());
var newContentBlob = blobClient.GetBlockBlobReference(newMediaContent.GetMediaBlobPath());
if (oldContentBlob.Exists() && !newContentBlob.Exists())
{
try
{
newContentBlob.CopyFromBlob(oldContentBlob);
}
catch (Exception e)
{
using (Stream stream = new MemoryStream())
{
oldContentBlob.DownloadToStream(stream);
stream.Position = 0;
newContentBlob.UploadFromStream(stream);
stream.Dispose();
}
}
newContentBlob.Metadata["FileName"] = StorageNamesEncoder.EncodeBlobName(newMediaContent.FileName);
if (!string.IsNullOrEmpty(oldContentBlob.Metadata["UserId"]))
{
newContentBlob.Metadata["UserId"] = oldContentBlob.Metadata["UserId"];
}
if (!string.IsNullOrEmpty(oldContentBlob.Metadata["Published"]))
{
newContentBlob.Metadata["Published"] = oldContentBlob.Metadata["Published"];
}
if (!string.IsNullOrEmpty(oldContentBlob.Metadata["Size"]))
{
newContentBlob.Metadata["Size"] = oldContentBlob.Metadata["Size"];
}
if (oldContentBlob.Metadata.AllKeys.Contains("AlternateText"))
{
newContentBlob.Metadata["AlternateText"] = oldContentBlob.Metadata["AlternateText"];
}
if (oldContentBlob.Metadata.AllKeys.Contains("Description"))
{
newContentBlob.Metadata["Description"] = oldContentBlob.Metadata["Description"];
}
if (oldContentBlob.Metadata.AllKeys.Contains("Title"))
{
newContentBlob.Metadata["Title"] = oldContentBlob.Metadata["Title"];
}
newContentBlob.SetMetadata();
oldContentBlob.DeleteIfExists();
}
}
示例8: MoveContent
private static void MoveContent(MediaContent oldMediaContent, MediaContent newMediaContent)
{
var blobClient = CloudStorageAccountHelper.GetStorageAccount().CreateCloudBlobClient();
var oldContentBlob = blobClient.GetBlockBlobReference(oldMediaContent.GetMediaBlobPath());
var newContentBlob = blobClient.GetBlockBlobReference(newMediaContent.GetMediaBlobPath());
if (oldContentBlob.Exists() && !newContentBlob.Exists())
{
newContentBlob.CopyFromBlob(oldContentBlob);
newContentBlob.Metadata["FileName"] = newMediaContent.FileName;
newContentBlob.SetMetadata();
oldContentBlob.DeleteIfExists();
}
}
示例9: 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;
}