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

S3 Missing Key #21

Open
silverbuggy opened this issue Sep 18, 2020 · 1 comment
Open

S3 Missing Key #21

silverbuggy opened this issue Sep 18, 2020 · 1 comment

Comments

@silverbuggy
Copy link

Persistently getting S3 Missing Key despite correct credentials. Any help would be appreciated:

import express from "express";
import s3Proxy from "s3-proxy";
const app = express();
app.get("/*", s3Proxy({
bucket: "ymw",
accessKeyId: "XXX",
secretAccessKey: "YYY",
overrideCacheControl: "max-age=100000",
defaultKey: "earth.jpg"
}));
app.listen(80, () => {
console.log("App listening on port 80")
})

@jstrese
Copy link

jstrese commented Oct 29, 2020

@silverbuggy the "Missing Key" error indicates that the object can't be found in the bucket.. I would double check the path of the content.

When testing locally I also ran into this error as well. After stepping through the GetObject method in s3-proxy I noticed that my Express route was being added to the S3 path as such:

app.get('/serve/*', s3Proxy({ ... prefix: 'MyDirectory' ... }));

localhost:3000/serve/index.html

This path was being rendered as: s3://MyDirectory/serve/index.html

To work around this I did the following:

app.get('/serve/*', (req, res, next) =>{
  req.baseUrl = '/serve';
  
  s3Proxy({
    bucket: 'MyBucket',
    prefix: 'MyDirectory',
  })(req, res, next);
});

I hope this helps - not totally sure if we are experiencing the same issue 😄

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

2 participants