当前位置: 首页>>代码示例>>C#>>正文


C# MediaContent.GetMediaBlobPath方法代码示例

本文整理汇总了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();
        }
开发者ID:Epitomy,项目名称:CMS,代码行数:8,代码来源:MediaContentProvider.cs

示例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();
            }
        }
开发者ID:Epitomy,项目名称:CMS,代码行数:19,代码来源:MediaContentProvider.cs

示例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();
        }
开发者ID:Epitomy,项目名称:CMS,代码行数:16,代码来源:MediaContentProvider.cs

示例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();
        }
开发者ID:Epitomy,项目名称:CMS,代码行数:10,代码来源:MediaContentProvider.cs

示例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);
            }
        }
开发者ID:Godoy,项目名称:CMS,代码行数:14,代码来源:MediaContentProvider.cs

示例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;
        }
开发者ID:Godoy,项目名称:CMS,代码行数:22,代码来源:MediaContentProvider.cs

示例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();
            }

        }
开发者ID:Godoy,项目名称:CMS,代码行数:53,代码来源:MediaContentProvider.cs

示例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();
            }
        }
开发者ID:ZhiGuangHuang,项目名称:CMS,代码行数:14,代码来源:MediaContentProvider.cs

示例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;
        }
开发者ID:ZhiGuangHuang,项目名称:CMS,代码行数:22,代码来源:MediaContentProvider.cs


注:本文中的Kooboo.CMS.Content.Models.MediaContent.GetMediaBlobPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。