s3-proxy icon indicating copy to clipboard operation
s3-proxy copied to clipboard

S3 Missing Key

Open silverbuggy opened this issue 4 years ago • 1 comments

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") })

silverbuggy avatar Sep 18 '20 13:09 silverbuggy

@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 😄

jstrese avatar Oct 29 '20 10:10 jstrese