stavro / arc

:paperclip: Flexible file upload and attachment library for Elixir
1.16k stars 210 forks source link

Uploading to S3 fails #249

Closed hahuang65 closed 6 years ago

hahuang65 commented 6 years ago

Environment

Setup:

# config.exs
# Configures Arc
config :arc,
  storage: Arc.Storage.S3,
  bucket: "myapp-#{Mix.env}-images"

config :ex_aws,
  access_key_id: [{:system, "MYAPP_AWS_ACCESS_ID"}, :instance_role],
  secret_access_key: [{:system, "MYAPP_AWS_ACCESS_SECRET"}, :instance_role]

Expected behavior

Upload should go through.

Actual behavior

     ** (EXIT from #PID<0.544.0>) an exception was raised:
         ** (CaseClauseError) no case clause matching: {:ok, %{body: "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Error><Code>PermanentRedirect</Code><Message>The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.</Message><Bucket>myapp-test-images</Bucket><Endpoint>myapp-test-images.s3.amazonaws.com</Endpoint><RequestId>1B1207552CD40610</RequestId><HostId>a4Pih+t7hSPOj4weBWKxK4/UFXQWAw3Apf05oV010BMIrUl5UJnKzJcG2safLXKccWMmwIMvMU0=</HostId></Error>", headers: [{"x-amz-bucket-region", "us-west-1"}, {"x-amz-request-id", "1B1207552CD40610"}, {"x-amz-id-2", "a4Pih+t7hSPOj4weBWKxK4/UFXQWAw3Apf05oV010BMIrUl5UJnKzJcG2safLXKccWMmwIMvMU0="}, {"Content-Type", "application/xml"}, {"Transfer-Encoding", "chunked"}, {"Date", "Tue, 03 Apr 2018 03:13:10 GMT"}, {"Server", "AmazonS3"}], status_code: 301}}
             (ex_aws) lib/ex_aws/request.ex:38: ExAws.Request.request_and_retry/7
             (ex_aws) lib/ex_aws/operation/s3.ex:40: ExAws.Operation.ExAws.Operation.S3.perform/2
             (ex_aws) lib/ex_aws/s3/upload.ex:40: ExAws.S3.Upload.initialize/2
             (ex_aws) lib/ex_aws/s3/upload.ex:82: ExAws.Operation.ExAws.S3.Upload.perform/2
             (arc) lib/arc/storage/s3.ex:57: Arc.Storage.S3.do_put/3
             (elixir) lib/task/supervised.ex:88: Task.Supervised.do_apply/2
             (elixir) lib/task/supervised.ex:38: Task.Supervised.reply/5
             (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
hahuang65 commented 6 years ago

I'm sorry, I failed to see https://github.com/stavro/arc/issues/23 and https://github.com/stavro/arc/issues/87 in my previous search.