本文整理汇总了C#中BlobServiceClient.PutBlockBlob方法的典型用法代码示例。如果您正苦于以下问题:C# BlobServiceClient.PutBlockBlob方法的具体用法?C# BlobServiceClient.PutBlockBlob怎么用?C# BlobServiceClient.PutBlockBlob使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BlobServiceClient
的用法示例。
在下文中一共展示了BlobServiceClient.PutBlockBlob方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PutBlockBlob_LeasedBlobWithCorrectLeaseIdSpecified_UploadsBlobSuccessfully
public void PutBlockBlob_LeasedBlobWithCorrectLeaseIdSpecified_UploadsBlobSuccessfully()
{
var containerName = _util.GenerateSampleContainerName(_runId);
var blobName = _util.GenerateSampleBlobName(_runId);
_util.CreateContainer(containerName);
_util.CreateBlockBlob(containerName, blobName);
var correctLease = _util.LeaseBlob(containerName, blobName);
IBlobServiceClient client = new BlobServiceClient(AccountSettings);
var data = Encoding.UTF8.GetBytes("unit test content");
client.PutBlockBlob(containerName, blobName, data, leaseId: correctLease);
_util.AssertBlobExists(containerName, blobName, BlobType.BlockBlob);
}
示例2: PutBlockBlob_LeasedBlobWithIncorrectLeaseGiven_ThrowsLeaseIdMismatchWithBlobOperationAzureException
public void PutBlockBlob_LeasedBlobWithIncorrectLeaseGiven_ThrowsLeaseIdMismatchWithBlobOperationAzureException()
{
var containerName = _util.GenerateSampleContainerName(_runId);
var blobName = _util.GenerateSampleBlobName(_runId);
_util.CreateContainer(containerName);
_util.CreateBlockBlob(containerName, blobName);
_util.LeaseBlob(containerName, blobName);
IBlobServiceClient client = new BlobServiceClient(AccountSettings);
var data = Encoding.UTF8.GetBytes("unit test content");
client.PutBlockBlob(containerName, blobName, data, leaseId: GetGuidString());
// throws exception
}
示例3: PutBlockBlob_WithMetadata_UploadsMetadata
public void PutBlockBlob_WithMetadata_UploadsMetadata()
{
var containerName = _util.GenerateSampleContainerName(_runId);
var blobName = _util.GenerateSampleBlobName(_runId);
_util.CreateContainer(containerName);
IBlobServiceClient client = new BlobServiceClient(AccountSettings);
var data = Encoding.UTF8.GetBytes("unit test content");
var expectedMetadata = new Dictionary<string, string>(){
{ "firstValue", "1" },
{ "secondValue", "2"}
};
client.PutBlockBlob(containerName, blobName, data, metadata: expectedMetadata);
var blob = _util.AssertBlobExists(containerName, blobName, BlobType.BlockBlob);
Assert.IsTrue(blob.Metadata.Any(m => m.Key == "firstValue" && m.Value == "1"), "First value is missing or incorrect");
Assert.IsTrue(blob.Metadata.Any(m => m.Key == "secondValue" && m.Value == "2"), "Second value is missing or incorrect");
}
示例4: PutBlockBlob_RequiredArgsOnly_UploadsBlobSuccessfully
public void PutBlockBlob_RequiredArgsOnly_UploadsBlobSuccessfully()
{
var containerName = _util.GenerateSampleContainerName(_runId);
var blobName = _util.GenerateSampleBlobName(_runId);
_util.CreateContainer(containerName);
IBlobServiceClient client = new BlobServiceClient(AccountSettings);
var data = Encoding.UTF8.GetBytes("unit test content");
client.PutBlockBlob(containerName, blobName, data);
_util.AssertBlobExists(containerName, blobName, BlobType.BlockBlob);
}
示例5: PutBlockBlob_WithIncorrectContentMD5_ThrowsMD5MismatchAzureException
public void PutBlockBlob_WithIncorrectContentMD5_ThrowsMD5MismatchAzureException()
{
var containerName = _util.GenerateSampleContainerName(_runId);
var blobName = _util.GenerateSampleBlobName(_runId);
_util.CreateContainer(containerName);
IBlobServiceClient client = new BlobServiceClient(AccountSettings);
var data = Encoding.UTF8.GetBytes("unit test content");
var someOtherData = Encoding.UTF8.GetBytes("different content");
var incorrectContentMD5 = Convert.ToBase64String((MD5.Create()).ComputeHash(someOtherData));
client.PutBlockBlob(containerName, blobName, data, contentMD5: incorrectContentMD5);
// expects exception
}
示例6: PutBlockBlob_WithCacheControl_UploadsWithCacheControl
public void PutBlockBlob_WithCacheControl_UploadsWithCacheControl()
{
var containerName = _util.GenerateSampleContainerName(_runId);
var blobName = _util.GenerateSampleBlobName(_runId);
_util.CreateContainer(containerName);
IBlobServiceClient client = new BlobServiceClient(AccountSettings);
var data = Encoding.UTF8.GetBytes("unit test content");
const string expectedCacheControl = "123-ABC";
client.PutBlockBlob(containerName, blobName, data, cacheControl: expectedCacheControl);
var blob = _util.AssertBlobExists(containerName, blobName, BlobType.BlockBlob);
Assert.AreEqual(expectedCacheControl, blob.Properties.CacheControl);
}
示例7: PutBlockBlob_WithContentMD5_UploadsWithSpecifiedContentMD5
public void PutBlockBlob_WithContentMD5_UploadsWithSpecifiedContentMD5()
{
var containerName = _util.GenerateSampleContainerName(_runId);
var blobName = _util.GenerateSampleBlobName(_runId);
_util.CreateContainer(containerName);
IBlobServiceClient client = new BlobServiceClient(AccountSettings);
var data = Encoding.UTF8.GetBytes("unit test content");
var expectedContentMD5 = Convert.ToBase64String((MD5.Create()).ComputeHash(data));
client.PutBlockBlob(containerName, blobName, data, contentMD5: expectedContentMD5);
var blob = _util.AssertBlobExists(containerName, blobName, BlobType.BlockBlob);
//this next test is not a real one, just for roundtrip verification
Assert.AreEqual(expectedContentMD5, blob.Properties.ContentMD5);
}
示例8: PutBlockBlob_WithContentLanguage_UploadsWithSpecifiedContentLanguage
public void PutBlockBlob_WithContentLanguage_UploadsWithSpecifiedContentLanguage()
{
var containerName = _util.GenerateSampleContainerName(_runId);
var blobName = _util.GenerateSampleBlobName(_runId);
_util.CreateContainer(containerName);
IBlobServiceClient client = new BlobServiceClient(AccountSettings);
var data = Encoding.UTF8.GetBytes("unit test content");
const string expectedContentLanguage = "gibberish";
client.PutBlockBlob(containerName, blobName, data, contentLanguage: expectedContentLanguage);
var blob = _util.AssertBlobExists(containerName, blobName, BlobType.BlockBlob);
Assert.AreEqual(expectedContentLanguage, blob.Properties.ContentLanguage);
}
示例9: PutBlockBlob_LeasedBlobWithInvalidLeaseGiven_ThrowsArgumentException
public void PutBlockBlob_LeasedBlobWithInvalidLeaseGiven_ThrowsArgumentException()
{
var containerName = _util.GenerateSampleContainerName(_runId);
var blobName = _util.GenerateSampleBlobName(_runId);
IBlobServiceClient client = new BlobServiceClient(AccountSettings);
var data = Encoding.UTF8.GetBytes("unit test content");
client.PutBlockBlob(containerName, blobName, data, leaseId: InvalidLeaseId);
// throws exception
}
示例10: PutBlockBlob_WithContentEncoding_UploadsWithSpecifiedContentEncoding
public void PutBlockBlob_WithContentEncoding_UploadsWithSpecifiedContentEncoding()
{
var containerName = GenerateSampleContainerName();
var blobName = GenerateSampleBlobName();
CreateContainer(containerName);
IBlobServiceClient client = new BlobServiceClient(AccountSettings);
var data = Encoding.UTF8.GetBytes("unit test content");
const string expectedContentEncoding = "UTF8";
client.PutBlockBlob(containerName, blobName, data, contentEncoding: expectedContentEncoding);
var blob = AssertBlobExists(containerName, blobName, BlobType.BlockBlob);
Assert.AreEqual(expectedContentEncoding, blob.Properties.ContentEncoding);
}
示例11: PutBlockBlob_LeasedBlobWithNoLeaseGiven_ThrowsLeaseIdMissingAzureException
public void PutBlockBlob_LeasedBlobWithNoLeaseGiven_ThrowsLeaseIdMissingAzureException()
{
var containerName = GenerateSampleContainerName();
var blobName = GenerateSampleBlobName();
CreateContainer(containerName);
CreateBlockBlob(containerName, blobName);
LeaseBlob(containerName, blobName);
IBlobServiceClient client = new BlobServiceClient(AccountSettings);
var data = Encoding.UTF8.GetBytes("unit test content");
client.PutBlockBlob(containerName, blobName, data);
// throws exception
}