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

Endpoint error for all S3 requests #70

Open
tmattio opened this issue Dec 12, 2019 · 2 comments
Open

Endpoint error for all S3 requests #70

tmattio opened this issue Dec 12, 2019 · 2 comments
Labels

Comments

@tmattio
Copy link

tmattio commented Dec 12, 2019

I am trying to use the S3 API. I tried both ListObjects and GetObjects.

For both, the result is the same - the answer from the server is not the one expected:

<?xml version="1.0" encoding="UTF-8"?>
<ListAllMyBucketsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
...
</ListAllMyBucketsResult>

Vs

<?xml version="1.0" encoding="UTF-8"?>
<GetObjectOutput>
...
</GetObjectOutput>

Here is the code I use:

let downloadFile = (filename) => {
  let settings = Config.settings;

  let run_request =
    Aws_lwt.Runtime.run_request(
      ~access_key=settings.accessKey,
      ~secret_key=settings.secretKey,
      ~region=settings.region,
      (module Aws_s3.GetObject),
      Aws_s3.Types.GetObjectRequest.make(
        ~bucket=settings.bucket,
        ~key=filename,
        (),
      ),
    );

  Lwt_main.run(run_request);
};

Where settings.bucket = "bucket-name" and settings.region = "us-east-1".

When reading the documentation, I am under the impression that the host endpoint to target should be:
bucket-name.s3.amazonaws.com, but from what I see, the library targets s3.amazonaws.com, which might explain issue.

@tmattio tmattio changed the title Endpoint error for S3 Endpoint error for all S3 requests Dec 12, 2019
@tmcgilchrist
Copy link
Collaborator

First thanks for taking the time to checkout the library (unfortunately I've been offline for holidays for most of the last month otherwise I'd have replied earlier).

The S3 library still needs a bunch of work before it can be used. Your investigations are correct the URL structure is incorrect and needs fixing. Have a look at the Endpoints module and how that is used to build the url structure for the S3 request, it needs to look at the request and pull the bucket name out of it. I'll have some time later this week to look at this.

Thanks

@tmcgilchrist
Copy link
Collaborator

Further to the S3 url fix there are issues with deserialising the responses from AWS.

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

No branches or pull requests

2 participants