amazon-archives/serverless-image-resizing

Bit more detail on event.queryStringParameters.key

Closed this issue · 0 comments

Hi

This looks very helpful.

Is there any chance you could expand a bit on this, at line 13, for a beginner:

const key = event.queryStringParameters.key;

From the following regex in line 14, it looks like queryStringParameters.key gets everything after the initial protocol and host, so for:

http://[BucketWebsiteHost]/300x300/image.png

queryStringParameters.key will return 300x300/image.png. Is this right? It looks more like a path than a key/value pair to me.

I would have thought that a key in a url would come after a ?, so for something like

http://[BucketWebsiteHost]/300x300/image.png?filename=myfile

event.queryStringParameters.key would return 1 key, filename, relating to one value, myfile.

Is there some default position I'm not aware of?

I'm trying to get some clarity so that I can structure my incoming urls in a way that can be easily and repeatably parsed whilst also leaving some flexibility for adding functionality later.

Thanks

Tom