Skip to content

Commit

Permalink
Fixed the issue where it cannot use the create_block_blob method with…
Browse files Browse the repository at this point in the history
… an IO/File object
  • Loading branch information
yaxia committed Nov 25, 2016
1 parent c631c29 commit e62ff95
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
3 changes: 2 additions & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
2016.11 - version 0.11.4-preview

ALL
* Removed the unnecessary dependencies. This resolves: [#55](https://github.com/Azure/azure-storage-ruby/issues/55), [#67](https://github.com/Azure/azure-storage-ruby/issues/67)
* Removed the unnecessary dependencies. [#55](https://github.com/Azure/azure-storage-ruby/issues/55), [#67](https://github.com/Azure/azure-storage-ruby/issues/67)

BLOB
* Fixed the issue when checking the content encoding.
* Fixed the wrong "Content-Encoding" value in the test cases.
* Fixed the issue where it cannot use the `create_block_blob` method with an IO/File object. [#61](https://github.com/Azure/azure-storage-ruby/issues/61)

2016.10 - version 0.11.3-preview

Expand Down
2 changes: 1 addition & 1 deletion lib/azure/storage/blob/blob_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def initialize(options = {})

def call(method, uri, body=nil, headers={}, options={})
# Force the request.body to the content encoding of specified in the header
if headers && !body.nil? && ((body.encoding.to_s <=> 'ASCII_8BIT') != 0)
if headers && !body.nil? && (body.is_a? String) && ((body.encoding.to_s <=> 'ASCII_8BIT') != 0)
if headers['x-ms-blob-content-type'].nil?
Service::StorageService.with_header headers, 'x-ms-blob-content-type', "text/plain; charset=#{body.encoding.to_s}"
else
Expand Down
17 changes: 17 additions & 0 deletions test/integration/blob/block_blob_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,23 @@
blob = subject.create_block_blob container_name, blob_name, content
blob.name.must_equal blob_name
end

it 'creates a block blob with IO' do
begin
file = File.open blob_name, 'w+'
file.write content
file.seek 0
subject.create_block_blob container_name, blob_name, file
blob = subject.get_blob_properties container_name, blob_name
blob.name.must_equal blob_name
blob.properties[:content_length].must_equal content.length
ensure
unless file.nil?
file.close
File.delete blob_name
end
end
end

it 'should create a block blob with spaces in name' do
blob_name = 'blob with spaces'
Expand Down

0 comments on commit e62ff95

Please sign in to comment.