waynehoover / s3_direct_upload

Direct Upload to Amazon S3 With CORS
MIT License
652 stars 333 forks source link

Frankfurt AWS4? #204

Open OShalaby-zz opened 9 years ago

OShalaby-zz commented 9 years ago

Hi,

Thanks alot waynehoover for this great gem. I'm new to AWS S3. I have a frankfurt bucket and I get the "Upload failed due to timeout" error and in the browser console I have:

<Error><Code>InvalidRequest</Code><Message>The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256.</Message>

I read on the AWS docs that Frankfurt's signature is V4 only, so in the s3_direct_upload.rb in initializers I added:

AWS.config(
    region: 'eu-central-1',
    s3_signature_version: :v4
)
S3DirectUpload.config do |c|
  c.access_key_id     = "my_key"
  c.secret_access_key = "my_secret_key"
  c.bucket            = "my_bucket"
  c.region            = "s3-eu-central-1"
  c.url = "https://#{c.bucket}.#{c.region}.amazonaws.com/"
end

Also in the docs I saw: Deriving the Signing Key V4 using Ruby:

def getSignatureKey key, dateStamp, regionName, serviceName
    kDate    = OpenSSL::HMAC.digest('sha256', "AWS4" + key, dateStamp)
    kRegion  = OpenSSL::HMAC.digest('sha256', kDate, regionName)
    kService = OpenSSL::HMAC.digest('sha256', kRegion, serviceName)
    kSigning = OpenSSL::HMAC.digest('sha256', kService, "aws4_request")

    kSigning
end

but I'm not really sure what to do with that block in association with s3 direct upload...any help? thanks.

hakunin commented 9 years ago

https://github.com/RobotsAndPencils/s3_direct_upload this branch works for new zones