ysugimoto/aws-lambda-image

Preserve Relative Path

Closed this issue · 4 comments

If an image is uploaded in foo/bar/image.png then it would be best if the resized images were added to /resized/small/foo/bar/image.png instead of the current behaviour of putting it in resized/small/image.png. This would allow apps that use custom paths to work better.

Simple fix if you know all your images are in sub-folders, in ImageReducer.js, replace "dir + image.baseName" with "dir + image.dirName + "/" + image.baseName,"

The PR is tested across root and sub-folders as well as with and without options.directory. If you could merge that would be swell 😄

@Webpal thanks for the pointer. A minor nitpick dir + image.dirName + "/" + image.baseName will be buggy if image is uploaded to bucket root, resulting in two slashes.

Hello @ysugimoto I was trying to replicate this in latest build. But couldn't get it to work.

Any help would be great.