dvonlehman / s3-proxy

4front plugin to proxy read calls to S3
50 stars 29 forks source link

Doesn't work if the object key has non-ASCII characters #30

Closed Moebits closed 2 years ago

Moebits commented 2 years ago

I am getting an error when an object is named something that contains non-ascii characters, like 無題.jpg:

TypeError [ERR_INVALID_CHAR]: Invalid character in header content ["x-4front-s3-proxy-key"]

I have found the offending line in your code:

var headerPrefix = req.app.settings.customHttpHeaderPrefix || 'x-4front-';
res.setHeader(headerPrefix + 's3-proxy-key', s3Params.Key);

res.setHeader doesn't support non-ascii characters, so you need to strip all non-ascii characters from the key or wrap this in a try/catch block. I don't really understand what the point of writing this header is, I will be forking this project with the line removed since this seems to be unmaintained for the most part.

Moebits commented 2 years ago

Also, this library makes a lot of LIST requests, which is limited to 2000/mo on the AWS free tier... I hit the free tier limit in a few days and I suspect it was because of this library.

I figured out that all I needed to do is run s3.getObject() on each endpoint and send it to the client, so I will no longer be using this library.