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


C# CloudBlockBlob.SetMetadata方法代码示例

本文整理汇总了C#中Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob.SetMetadata方法的典型用法代码示例。如果您正苦于以下问题:C# CloudBlockBlob.SetMetadata方法的具体用法?C# CloudBlockBlob.SetMetadata怎么用?C# CloudBlockBlob.SetMetadata使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob的用法示例。


在下文中一共展示了CloudBlockBlob.SetMetadata方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddContainerMetadata

        public static void AddContainerMetadata(CloudBlockBlob blob, object fileUploadObj)
        {
            var obj = ((BlobStorage.Models.UploadDataModel)fileUploadObj);
            //Add some metadata to the container.


            if (IsNotNull(obj.Category))
                blob.Metadata["category"] = obj.Category;
            else
                blob.Metadata["category"] = "Other";

            if (IsNotNull(obj.Name))
                blob.Metadata["name"] = obj.Name;
            else
                blob.Metadata["name"] = "Null";

            if (IsNotNull(obj.Number))
                blob.Metadata["number"] = obj.Number;
            else
                blob.Metadata["number"] = "Null";

            if (IsNotNull(obj.Email))
                blob.Metadata["email"] = obj.Email;
            else
                blob.Metadata["email"] = "Null";

            if (IsNotNull(obj.Comments))
                blob.Metadata["comments"] = obj.Comments;
            else
                blob.Metadata["comments"] = "Null";

            //Set the container's metadata.
            blob.SetMetadata();
        }
开发者ID:rohngonnarock,项目名称:BlobStorage,代码行数:34,代码来源:Todo.cs

示例2: revertFromSnapshot

        public void revertFromSnapshot(CloudBlockBlob blobRef, CloudBlockBlob snapshot)
        {
            try
            {

                    blobRef.StartCopyFromBlob(snapshot);
                    DateTime timestamp = DateTime.Now;
                    blobRef.FetchAttributes();
                    snapshot.FetchAttributes();
                    string time = snapshot.Metadata["timestamp"];
                    blobRef.Metadata["timestamp"] = timestamp.ToUniversalTime().ToString("MM/dd/yyyy HH:mm:ss");
                    blobRef.SetMetadata();
                    blobRef.CreateSnapshot();
                    //System.Windows.Forms.MessageBox.Show("revert success");

                    Program.ClientForm.addtoConsole("Successfully Reverted with time: " + time);
                    Program.ClientForm.ballon("Successfully Reverted! ");

            }
            catch (Exception e)
            {
                Program.ClientForm.addtoConsole("Exception:" + e.Message);
                //System.Windows.Forms.MessageBox.Show(e.ToString());
            }
        }
开发者ID:hangmiao,项目名称:DBLike,代码行数:25,代码来源:VCmanager.revert.cs

示例3: UpdateBlobMetadata

 /// <summary>
 /// Updates the BLOB metadata.
 /// </summary>
 /// <param name="package">The package.</param>
 /// <param name="blob">The BLOB.</param>
 private void UpdateBlobMetadata(IPackage package, CloudBlockBlob blob)
 {
     blob.Metadata[Constants.LatestModificationDate] = DateTimeOffset.Now.ToString();
     var azurePackage = Mapper.Map<AzurePackage>(package);
     //blob.Metadata[AzurePropertiesConstants.Package] = JsonConvert.SerializeObject(azurePackage);
     _packageSerializer.SaveToMetadata(azurePackage, blob);
     blob.SetMetadata();
 }
开发者ID:kevinhillinger,项目名称:Nuget.Server.AzureStorage,代码行数:13,代码来源:AzureServerPackageRepository+.cs

示例4: BlobWriteExpectLeaseSuccess

        /// <summary>
        /// Test blob writing, expecting success.
        /// </summary>
        /// <param name="testBlob">The blob to test.</param>
        /// <param name="sourceBlob">A blob to use as the source of a copy.</param>
        /// <param name="testAccessCondition">The access condition to use.</param>
        private void BlobWriteExpectLeaseSuccess(CloudBlockBlob testBlob, CloudBlob sourceBlob, AccessCondition testAccessCondition)
        {
            testBlob.SetMetadata(testAccessCondition, null /* options */);
            testBlob.SetProperties(testAccessCondition, null /* options */);
            UploadText(testBlob, "No Problem", Encoding.UTF8, testAccessCondition, null /* options */);
            testBlob.StartCopy(TestHelper.Defiddler(sourceBlob.Uri), null /* source access condition */, testAccessCondition, null /* options */);

            while (testBlob.CopyState.Status == CopyStatus.Pending)
            {
                Thread.Sleep(1000);
                testBlob.FetchAttributes();
            }

            Stream stream = testBlob.OpenWrite(testAccessCondition, null /* options */);
            stream.WriteByte(0);
            stream.Flush();

            testBlob.Delete(DeleteSnapshotsOption.None, testAccessCondition, null /* options */);
        }
开发者ID:benaadams,项目名称:azure-storage-net,代码行数:25,代码来源:LeaseTests.cs

示例5: BlobWriteExpectLeaseFailure

        /// <summary>
        /// Test blob write and creation, expecting lease failure.
        /// </summary>
        /// <param name="testBlob">The blob to test.</param>
        /// <param name="sourceBlob">A blob to use as the source of a copy.</param>
        /// <param name="testAccessCondition">The failing access condition to use.</param>
        /// <param name="expectedErrorCode">The expected error code.</param>
        /// <param name="description">The reason why these calls should fail.</param>
        private void BlobWriteExpectLeaseFailure(CloudBlockBlob testBlob, CloudBlockBlob sourceBlob, AccessCondition testAccessCondition, HttpStatusCode expectedStatusCode, string expectedErrorCode, string description)
        {
            this.BlobCreateExpectLeaseFailure(testBlob, sourceBlob, testAccessCondition, expectedStatusCode, expectedErrorCode, description);

            TestHelper.ExpectedException(
                () => testBlob.SetMetadata(testAccessCondition, null /* options */),
                description + " (Set Metadata)",
                expectedStatusCode,
                expectedErrorCode);
            TestHelper.ExpectedException(
                () => testBlob.SetProperties(testAccessCondition, null /* options */),
                description + " (Set Properties)",
                expectedStatusCode,
                expectedErrorCode);
            TestHelper.ExpectedException(
                () => testBlob.Delete(DeleteSnapshotsOption.None, testAccessCondition, null /* options */),
                description + " (Delete)",
                expectedStatusCode,
                expectedErrorCode);
        }
开发者ID:benaadams,项目名称:azure-storage-net,代码行数:28,代码来源:LeaseTests.cs

示例6: SaveToMetadata

        public void SaveToMetadata(AzurePackage package, CloudBlockBlob blob)
        {
            blob.Metadata["Id"] = package.Id;
            blob.Metadata["Version"] = package.Version.ToString();
            if (!string.IsNullOrEmpty(package.Title))
            {
                blob.Metadata["Title"] = package.Title;
            }
            blob.Metadata["Authors"] = string.Join(",", package.Authors);
            blob.Metadata["Owners"] = string.Join(",", package.Owners);
            if (package.IconUrl != null)
            {
                blob.Metadata["IconUrl"] = package.IconUrl.AbsoluteUri;
            }
            if (package.LicenseUrl != null)
            {
                blob.Metadata["LicenseUrl"] = package.LicenseUrl.AbsoluteUri;
            }
            if (package.ProjectUrl != null)
            {
                blob.Metadata["ProjectUrl"] = package.ProjectUrl.AbsoluteUri;
            }
            blob.Metadata["RequireLicenseAcceptance"] = package.RequireLicenseAcceptance.ToString();
            blob.Metadata["DevelopmentDependency"] = package.DevelopmentDependency.ToString();
            blob.Metadata["Description"] = package.Description;
            if (!string.IsNullOrEmpty(package.Summary))
            {
                blob.Metadata["Summary"] = package.Summary;
            }
            blob.Metadata["ReleaseNotes"] = package.ReleaseNotes;
            if (!string.IsNullOrEmpty(package.Tags))
            {
                blob.Metadata["Tags"] = package.Tags;
            }
            blob.Metadata["Dependencies"] = this.Base64Encode(package.DependencySets.Select(Mapper.Map<AzurePackageDependencySet>).ToJson());
            blob.Metadata["IsAbsoluteLatestVersion"] = package.IsAbsoluteLatestVersion.ToString();
            blob.Metadata["IsLatestVersion"] = package.IsLatestVersion.ToString();
            blob.Metadata["MinClientVersion"] = package.MinClientVersion.ToString();
            blob.Metadata["Listed"] = package.Listed.ToString();

            blob.SetMetadata();
        }
开发者ID:rjygraham,项目名称:Nuget.Server.AzureStorage,代码行数:42,代码来源:AzurePackageSerializer.cs

示例7: SaveToMetadata

        public void SaveToMetadata(AzurePackage package, CloudBlockBlob blob)
        {
            blob.Metadata[PkgConsts.Id] = package.Id;
            blob.Metadata[PkgConsts.Version] = package.Version.ToString();
            if (!string.IsNullOrEmpty(package.Title))
            {
                blob.Metadata[PkgConsts.Title] = package.Title;
            }
            blob.Metadata[PkgConsts.Authors] = string.Join(",", package.Authors);
            blob.Metadata[PkgConsts.Owners] = string.Join(",", package.Owners);
            if (package.IconUrl != null)
            {
                blob.Metadata[PkgConsts.IconUrl] = package.IconUrl.AbsoluteUri;
            }
            if (package.LicenseUrl != null)
            {
                blob.Metadata[PkgConsts.LicenseUrl] = package.LicenseUrl.AbsoluteUri;
            }
            if (package.ProjectUrl != null)
            {
                blob.Metadata[PkgConsts.ProjectUrl] = package.ProjectUrl.AbsoluteUri;
            }
            blob.Metadata[PkgConsts.RequireLicenseAcceptance] = package.RequireLicenseAcceptance.ToString();
            blob.Metadata[PkgConsts.DevelopmentDependency] = package.DevelopmentDependency.ToString();
            blob.Metadata[PkgConsts.Description] = Base64Encode(package.Description);
            if (!string.IsNullOrEmpty(package.Summary))
            {
                blob.Metadata[PkgConsts.Summary] = Base64Encode(package.Summary);
            }
            if (!string.IsNullOrEmpty(package.ReleaseNotes))
            {
                blob.Metadata[PkgConsts.ReleaseNotes] = Base64Encode(package.ReleaseNotes);
            }
            if (!string.IsNullOrEmpty(package.Tags))
            {
                blob.Metadata[PkgConsts.Tags] = package.Tags;
            }
            if (!string.IsNullOrEmpty(package.Language))
            {
                blob.Metadata[PkgConsts.Language] = package.Language;
            }
            if (!string.IsNullOrEmpty(package.Copyright))
            {
                blob.Metadata[PkgConsts.Copyright] = Base64Encode(package.Copyright);
            }
            if (package.ReportAbuseUrl != null)
            {
                blob.Metadata[PkgConsts.ReportAbuseUrl] = package.ReportAbuseUrl.ToString();
            }
            blob.Metadata[PkgConsts.DownloadCount] = package.DownloadCount.ToString();

            blob.Metadata[PkgConsts.FrameworkAssemblies] = package.FrameworkAssemblies
                .Select(x => new AzureFrameworkAssemblyReference(x))
                .ToJson();
            blob.Metadata[PkgConsts.PackageAssemblyReferences] = package.PackageAssemblyReferences
                .Select(x => new AzurePackageReferenceSet(x))
                .ToJson();
            blob.Metadata[PkgConsts.AssemblyReferences] = package.AssemblyReferences
                .Select(x => new AzureDtoAssemblyReference(x))
                .ToJson();
            blob.Metadata[PkgConsts.Dependencies] = this.Base64Encode(package.DependencySets.Select(Mapper.Map<AzurePackageDependencySet>).ToJson());

            blob.Metadata[PkgConsts.IsAbsoluteLatestVersion] = package.IsAbsoluteLatestVersion.ToString();
            blob.Metadata[PkgConsts.IsLatestVersion] = package.IsLatestVersion.ToString();
            if (package.MinClientVersion != null)
            {
                blob.Metadata[PkgConsts.MinClientVersion] = package.MinClientVersion.ToString();
            }
            if (package.Published != null)
            {
                blob.Metadata[PkgConsts.Published] = package.Published.Value.ToString("yyyy-MM-ddTHH:mm:ssZ");
            }

            blob.Metadata[PkgConsts.Listed] = package.Listed.ToString();

            blob.SetMetadata();
        }
开发者ID:dstoreng,项目名称:nugget,代码行数:77,代码来源:AzurePackageSerializer.cs

示例8: SetCompressedFlag

 private static void SetCompressedFlag(CloudBlockBlob workItem)
 {
     workItem.Metadata.Add(new KeyValuePair<string, string>(CompressedFlag,
         "true"));
     workItem.SetMetadata();
 }
开发者ID:hossamdarwish,项目名称:Brisebois.WindowsAzure,代码行数:6,代码来源:BlobCompressor.cs


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