public async void PutBlockBlobIntelligentlyAsync_DefaultArgsOnly_CreatesBlockBlob() { var expectedData = Encoding.UTF8.GetBytes("test data"); var containerName = GenerateSampleContainerName(); var blobName = GenerateSampleBlobName(); IBlobServiceClientEx client = new BlobServiceClientEx(AccountSettings); CreateContainer(containerName); // Tempt it to do it in two uploads by specifying half megabyte await client.PutBlockBlobIntelligentlyAsync(expectedData.Length - 5, containerName, blobName, expectedData); AssertBlobExists(containerName, blobName, BlobType.BlockBlob); AssertBlockBlobContainsData(containerName, blobName, expectedData); }
public async void PutBlockBlobIntelligentlyAsync_DataSmallerThanMaxSingleUploadSize_CreatesBlockBlobWithOneUpload() { var expectedData = Encoding.UTF8.GetBytes("test data"); var expectedDataLength = expectedData.Length; var containerName = GenerateSampleContainerName(); var blobName = GenerateSampleBlobName(); IBlobServiceClientEx client = new BlobServiceClientEx(AccountSettings); CreateContainer(containerName); // Tempt it to do it in two uploads by specifying a blocksize smaller than the data length var response = await client.PutBlockBlobIntelligentlyAsync(expectedDataLength - 5, containerName, blobName, expectedData); AssertBlobOfSingleUpload(expectedData, containerName, blobName); AssertIsPutBlockBlobResponse(response); }
public async void PutBlockBlobIntelligentlyAsync_DataLargerThanMaxSingleUploadSize_CreatesBlockBlobWithMultipleUploads() { var expectedData = new byte[MaxIntelligentSingleBlobUploadSizeOverride + 5]; var containerName = GenerateSampleContainerName(); var blobName = GenerateSampleBlobName(); IBlobServiceClientEx client = new BlobServiceClientEx(AccountSettings, MaxIntelligentSingleBlobUploadSizeOverride); CreateContainer(containerName); var response = await client.PutBlockBlobIntelligentlyAsync(BlobServiceConstants.MaxSingleBlockUploadSize, containerName, blobName, expectedData); AssertBlobOfMultipleUploads(expectedData, containerName, blobName); AssertIsBlockListResponse(response); }
public async void PutBlockBlobIntelligentlyAsync_SingleUploadWithMetadata_CorrectMetadata() { var expectedData = new byte[1024]; var expectedMetadata = new Dictionary<string, string> { {"haikuLine1", "I dreamed I was in"}, {"haikuLine2", "A long-running endless loop"}, {"haikuLine3", "And then the next day"} }; var containerName = GenerateSampleContainerName(); var blobName = GenerateSampleBlobName(); IBlobServiceClientEx client = new BlobServiceClientEx(AccountSettings); CreateContainer(containerName); await client.PutBlockBlobIntelligentlyAsync(BlobServiceConstants.MaxSingleBlockUploadSize, containerName, blobName, expectedData, metadata: expectedMetadata); var metadata = GetBlobMetadata(containerName, blobName); AssertBlobOfSingleUpload(expectedData, containerName, blobName); Assert.AreEqual(expectedMetadata, metadata); }
public async void PutBlockBlobIntelligentlyAsync_SingleUploadWithCacheControl_CorrectContentCacheControl() { var expectedData = new byte[1024]; const string expectedCacheControl = "ponyfoo"; var containerName = GenerateSampleContainerName(); var blobName = GenerateSampleBlobName(); IBlobServiceClientEx client = new BlobServiceClientEx(AccountSettings); CreateContainer(containerName); await client.PutBlockBlobIntelligentlyAsync(BlobServiceConstants.MaxSingleBlockUploadSize, containerName, blobName, expectedData, cacheControl: expectedCacheControl); var properties = GetBlobProperties(containerName, blobName); AssertBlobOfSingleUpload(expectedData, containerName, blobName); Assert.AreEqual(expectedCacheControl, properties.CacheControl); }
public async void PutBlockBlobIntelligentlyAsync_SingleUploadWithContentMD5_CorrectContentMD5() { var expectedData = new byte[1024]; var expectedContentMD5 = Convert.ToBase64String(MD5.Create().ComputeHash(expectedData)); var containerName = GenerateSampleContainerName(); var blobName = GenerateSampleBlobName(); IBlobServiceClientEx client = new BlobServiceClientEx(AccountSettings); CreateContainer(containerName); await client.PutBlockBlobIntelligentlyAsync(BlobServiceConstants.MaxSingleBlockUploadSize, containerName, blobName, expectedData, contentMD5: expectedContentMD5); var properties = GetBlobProperties(containerName, blobName); AssertBlobOfSingleUpload(expectedData, containerName, blobName); Assert.AreEqual(expectedContentMD5, properties.ContentMD5); }
public async void PutBlockBlobIntelligentlyAsync_MultipleUploadsWithContentEncoding_CorrectContentEncoding() { const string expectedContentEncoding = "UTF8"; var expectedData = new byte[MaxIntelligentSingleBlobUploadSizeOverride + 5]; var containerName = GenerateSampleContainerName(); var blobName = GenerateSampleBlobName(); IBlobServiceClientEx client = new BlobServiceClientEx(AccountSettings, MaxIntelligentSingleBlobUploadSizeOverride); CreateContainer(containerName); await client.PutBlockBlobIntelligentlyAsync(BlobServiceConstants.MaxSingleBlockUploadSize, containerName, blobName, expectedData, contentEncoding: expectedContentEncoding); var properties = GetBlobProperties(containerName, blobName); AssertBlobOfMultipleUploads(expectedData, containerName, blobName); Assert.AreEqual(expectedContentEncoding, properties.ContentEncoding); }
public async void PutBlockBlobIntelligentlyAsync_SingleUploadWithContentLanguage_CorrectContentLanguage() { const string expectedContentLanguage = "ancient/yiddish"; var expectedData = new byte[1024]; var containerName = GenerateSampleContainerName(); var blobName = GenerateSampleBlobName(); IBlobServiceClientEx client = new BlobServiceClientEx(AccountSettings); CreateContainer(containerName); await client.PutBlockBlobIntelligentlyAsync(BlobServiceConstants.MaxSingleBlockUploadSize, containerName, blobName, expectedData, contentLanguage: expectedContentLanguage); var properties = GetBlobProperties(containerName, blobName); AssertBlobOfSingleUpload(expectedData, containerName, blobName); Assert.AreEqual(expectedContentLanguage, properties.ContentLanguage); }
public async void PutBlockBlobIntelligentlyAsync_MultipleUploadsWithCacheControl_CorrectContentCacheControl() { var expectedData = new byte[MaxIntelligentSingleBlobUploadSizeOverride + 5]; const string expectedCacheControl = "ponyfoo"; var containerName = _util.GenerateSampleContainerName(_runId); var blobName = _util.GenerateSampleBlobName(_runId); IBlobServiceClientEx client = new BlobServiceClientEx(AccountSettings, MaxIntelligentSingleBlobUploadSizeOverride); _util.CreateContainer(containerName); await client.PutBlockBlobIntelligentlyAsync(BlobServiceConstants.MaxSingleBlockUploadSize, containerName, blobName, expectedData, cacheControl: expectedCacheControl); var properties = _util.GetBlobProperties(containerName, blobName); _util.AssertBlobOfMultipleUploads(expectedData, containerName, blobName, MaxIntelligentSingleBlobUploadSizeOverride); Assert.AreEqual(expectedCacheControl, properties.CacheControl); }
public async void PutBlockBlobIntelligentlyAsync_MultipleUploadsWithContentMD5_CorrectContentMD5() { var expectedData = new byte[MaxIntelligentSingleBlobUploadSizeOverride + 5]; var expectedContentMD5 = Convert.ToBase64String(MD5.Create().ComputeHash(expectedData)); var containerName = _util.GenerateSampleContainerName(_runId); var blobName = _util.GenerateSampleBlobName(_runId); IBlobServiceClientEx client = new BlobServiceClientEx(AccountSettings, MaxIntelligentSingleBlobUploadSizeOverride); _util.CreateContainer(containerName); await client.PutBlockBlobIntelligentlyAsync(BlobServiceConstants.MaxSingleBlockUploadSize, containerName, blobName, expectedData, contentMD5: expectedContentMD5); var properties = _util.GetBlobProperties(containerName, blobName); _util.AssertBlobOfMultipleUploads(expectedData, containerName, blobName, MaxIntelligentSingleBlobUploadSizeOverride); Assert.AreEqual(expectedContentMD5, properties.ContentMD5); }
public async void PutBlockBlobIntelligentlyAsync_SingleUploadWithContentType_CorrectContentTypeSet() { const string expectedContentType = "foo/bar"; var expectedData = new byte[1024]; var containerName = _util.GenerateSampleContainerName(_runId); var blobName = _util.GenerateSampleBlobName(_runId); IBlobServiceClientEx client = new BlobServiceClientEx(AccountSettings); _util.CreateContainer(containerName); await client.PutBlockBlobIntelligentlyAsync(BlobServiceConstants.MaxSingleBlockUploadSize, containerName, blobName, expectedData, contentType: expectedContentType); var properties = _util.GetBlobProperties(containerName, blobName); _util.AssertBlobOfSingleUpload(expectedData, containerName, blobName, MaxIntelligentSingleBlobUploadSizeOverride); Assert.AreEqual(expectedContentType, properties.ContentType); }