Beispiel #1
0
        public async Task UploadAsync_Stream_Tags()
        {
            // Arrange
            await using DisposingContainer test = await GetTestContainerAsync();

            var        name = GetNewBlobName();
            BlobClient blob = InstrumentClient(test.Container.GetBlobClient(name));
            var        data = GetRandomBuffer(Constants.KB);
            IDictionary <string, string> tags    = BuildTags();
            BlobUploadOptions            options = new BlobUploadOptions
            {
                Tags = tags
            };

            // Act
            using (var stream = new MemoryStream(data))
            {
                await blob.UploadAsync(stream, options);
            }

            Response <GetBlobTagResult> response = await blob.GetTagsAsync();

            // Assert
            AssertDictionaryEquality(tags, response.Value.Tags);
        }
Beispiel #2
0
        public async Task UploadAsync_File_Tags()
        {
            // Arrange
            await using DisposingContainer test = await GetTestContainerAsync();

            var        name = GetNewBlobName();
            BlobClient blob = InstrumentClient(test.Container.GetBlobClient(name));
            var        data = GetRandomBuffer(Constants.KB);
            IDictionary <string, string> tags    = BuildTags();
            BlobUploadOptions            options = new BlobUploadOptions
            {
                Tags = tags
            };

            using (var stream = new MemoryStream(data))
            {
                var path = Path.GetTempFileName();

                try
                {
                    File.WriteAllBytes(path, data);

                    // Test that we can upload a read-only file.
                    File.SetAttributes(path, FileAttributes.ReadOnly);

                    // Act
                    await blob.UploadAsync(path, options);
                }
                finally
                {
                    if (File.Exists(path))
                    {
                        File.SetAttributes(path, FileAttributes.Normal);
                        File.Delete(path);
                    }
                }
            }

            Response <GetBlobTagResult> response = await blob.GetTagsAsync();

            // Assert
            AssertDictionaryEquality(tags, response.Value.Tags);
        }