feathersjs-ecosystem / feathers-blob

Feathers service for blob storage, like S3.
http://feathersjs.com
MIT License
92 stars 32 forks source link

Object which key contains '/' cannot be retrieved by REST on S3 #70

Closed claustres closed 3 years ago

claustres commented 4 years ago

Steps to reproduce

Create a storage service targeting a S3 bucket like bucket. Try to access an object in a "sub-directory" with a key like bucket/sub/file.

Expected behavior

The object is correctly retrieved.

Actual behavior

A 404 error is raised. It's probably because express interpret the id with a / as a different route.

System configuration

Tell us about the applicable parts of your setup.

Module versions: 2.1

NodeJS version: 8.16

Operating System: Windows

claustres commented 4 years ago

Probably linked to the fact that to handle something like this you need to use a wildcard in Express like app.get('/service/*') & req.params[0] while Feathers probably uses a standard parameter like app.get('/service/:id') & req.params.id.

green3g commented 3 years ago

I was able to overcome this - just encodeURIComponent(id) so the slashes get converted to %2f

claustres commented 3 years ago

Good catch, could you push a PR on this or point out where you added this fix? Thanks

green3g commented 3 years ago

I actually implemented this on the client side - as a simple before get hook.


context => {
    if(context.id.indexOf('/') > -1) {
        context.id = encodeUriComponent(context.id);
    }
    return context;
}
claustres commented 3 years ago

OK, as with REST the ID is part of the URL it should be encoded upfront so that it is correctly decoded, it will not help to try to encode it on the backend before calling AWS.

I think we can close this issue with your fix.