aristidb / aws

Amazon Web Services for Haskell
BSD 3-Clause "New" or "Revised" License
239 stars 108 forks source link

S3: invalid request #227

Closed mrkkrp closed 7 years ago

mrkkrp commented 7 years ago

I can't upload a file to S3, my usage is pretty straightforward:

{-# LANGUAGE OverloadedStrings #-}

module Main where

import Control.Monad
import Control.Monad.Trans.Resource (runResourceT)
import qualified Aws
import qualified Aws.Core as AC
import qualified Aws.S3 as S3
import qualified Network.HTTP.Client as L
import qualified Network.HTTP.Client.TLS as L

main :: IO ()
main = do
  creds <- AC.makeCredentials
    "access key" -- access key
    "secret access key" -- secret access key
  let awsConfig = Aws.Configuration
        { Aws.timeInfo = Aws.Timestamp
        , Aws.credentials = creds
        , Aws.logger = Aws.defaultLog Aws.Warning }
      s3Config = Aws.defServiceConfig
  manager <- L.newManager L.tlsManagerSettings
  void . runResourceT . Aws.pureAws awsConfig s3Config manager $
    S3.putObject "my-bucket" "something.txt" (L.RequestBodyBS "foo!")

And S3 says:

S3Error
  { s3StatusCode = Status {statusCode = 400, statusMessage = "Bad Request"}
  , s3ErrorCode = "InvalidRequest"
  , s3ErrorMessage = "The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256."
  , s3ErrorResource = Nothing
  , s3ErrorHostId = Just "UIs9WGFfyQ4szjtQHYiEL/OTPeFyKgtHhdNRO2B+vDRJDE+0Bi2GPvB9FCZ6hkN4xqrfRqL8cVo="
  , s3ErrorAccessKeyId = Nothing
  , s3ErrorStringToSign = Nothing
  , s3ErrorBucket = Nothing
  , s3ErrorEndpointRaw = Nothing
  , s3ErrorEndpoint = Nothing }

Maybe it's time to start using what it says to use?

mrkkrp commented 7 years ago

OK, looks like Frankfurt does not supprot V2. Could we merge #199 so I can at least put and get objects?

mrkkrp commented 7 years ago

I'll try amazonka instead, if aws still has such problems in 2017, I'm not sure about using it.

aristidb commented 7 years ago

Using amazonka is probably a more future-proof choice if it works for you. To be honest, if I had known that amazonka's approach of generating APIs from descriptor files is possible, I would've done it too.

As for #199, it's a work-in-progress and I don't think it's ready for merging.

I'm neither actively using nor developing on "aws" myself, but I do generally try to merge pull requests when they're ready for merging.

Given that you said you want to use amazonka and given that not supporting Frankfurt is a known issue, I will close this issue.