Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

blob upload fails with 400 when use_sas_auth_only=true #41

Open
grahamkenville opened this issue Aug 26, 2015 · 0 comments
Open

blob upload fails with 400 when use_sas_auth_only=true #41

grahamkenville opened this issue Aug 26, 2015 · 0 comments

Comments

@grahamkenville
Copy link

I'm writing a script to upload largish files. When I specify use_sas_auth_only it fails with a 400 error (see below). This is with waz-storage (1.3.6).

Thanks!


#!/usr/bin/env ruby

# gem install waz-storage --source http://gemcutter.org
require 'waz-blobs'

file_to_upload = "test.txt"

# Works:
# WAZ::Storage::Base.establish_connection!(:account_name => 'test', :access_key => 'key-goes-here')


# Doesn't work:
WAZ::Storage::Base.establish_connection!(:account_name => 'drbackup',
                                         :use_sas_auth_only => true,
                                         :sharedaccesssignature => 'key-goes-here'
                                         )


container = WAZ::Blobs::Container.new(:name=>'rubytest')

fd = IO.sysopen(file_to_upload, "r")
stream = IO.new(fd)


puts "Uploading"
container.upload(file_to_upload,
                 stream,
                 'application/octet-stream'
                 ) 

Script output:

Uploading
RestClient::BadRequest: 400 Bad Request
         return! at /usr/local/lib/jruby-1.7.17/lib/ruby/gems/shared/gems/rest-client-1.8.0/lib/restclient/abstract_response.rb:74
  process_result at /usr/local/lib/jruby-1.7.17/lib/ruby/gems/shared/gems/rest-client-1.8.0/lib/restclient/request.rb:495
        transmit at /usr/local/lib/jruby-1.7.17/lib/ruby/gems/shared/gems/rest-client-1.8.0/lib/restclient/request.rb:421
           start at /usr/local/lib/jruby-1.7.17/lib/ruby/1.9/net/http.rb:746
        transmit at /usr/local/lib/jruby-1.7.17/lib/ruby/gems/shared/gems/rest-client-1.8.0/lib/restclient/request.rb:413
         execute at /usr/local/lib/jruby-1.7.17/lib/ruby/gems/shared/gems/rest-client-1.8.0/lib/restclient/request.rb:176
         execute at /usr/local/lib/jruby-1.7.17/lib/ruby/gems/shared/gems/waz-storage-1.3.6/lib/waz/storage/core_service.rb:124
       put_block at /usr/local/lib/jruby-1.7.17/lib/ruby/gems/shared/gems/waz-storage-1.3.6/lib/waz/blobs/service.rb:158
          upload at /usr/local/lib/jruby-1.7.17/lib/ruby/gems/shared/gems/waz-storage-1.3.6/lib/waz/blobs/container.rb:144
          (root) at ./test.rb:26

Wireshark trace with a text file upload:

PUT /rubytest/test.txt?key-goes-here HTTP/1.1
Accept: */*; q=0.5, application/xml
Accept-Encoding: gzip, deflate
Content-Type: application/octet-stream
X-Ms-Date: Tue, 25 Aug 2015 20:55:22 GMT
Content-Length: 53
User-Agent: Ruby
Host: test.blob.core.windows.net

HTTP/1.1 400 An HTTP header that's mandatory for this request is not specified.
Content-Length: 295
Content-Type: application/xml
Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
x-ms-request-id: 1a58eb8b-0001-003a-7b78-df52be000000
x-ms-version: 2014-02-14
Date: Tue, 25 Aug 2015 20:55:21 GMT

...<?xml version="1.0" encoding="utf-8"?><Error><Code>MissingRequiredHeader</Code><Message>An HTTP header that's mandatory for this request is not specified.
RequestId:1a58eb8b-0001-003a-7b78-df52be000000
Time:2015-08-25T20:55:22.5160429Z</Message><HeaderName>x-ms-blob-type</HeaderName></Error>-----------
this is the test upload file
-----------

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant