本文整理汇总了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();
}
示例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());
}
}
示例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();
}
示例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 */);
}
示例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);
}
示例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();
}
示例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();
}
示例8: SetCompressedFlag
private static void SetCompressedFlag(CloudBlockBlob workItem)
{
workItem.Metadata.Add(new KeyValuePair<string, string>(CompressedFlag,
"true"));
workItem.SetMetadata();
}