While fetching images from your S3 bucket with special characters in the name, you would expect a
200 OK response but get a
404 NOT FOUND response. For example, let’s assume that there is a key
image%2Bexample.jpg in your S3 bucket & the request is made using
image+example.jpg in the URL. In this case ImageKit tries to fetch
image+example.jpg object from the S3 bucket, resulting in a 404 error as this object does not exist.
While adding S3 bucket as a source in your ImageKit account, you are now provided with an option to encode the keys while fetching the object from your S3 bucket. By default, this option is disabled. When enabled, the requests made while fetching images will be made using encoded keys.
Note: At present, this feature can only be enabled upon request. Please create a support ticket to get in touch with our team.
Let us take a look at the same example as above.
Suppose there is a key with name
image%2Bexample.jpg and the request is made using
image+example.jpg in the URL. With encoding enabled on this source, ImageKit tries to fetch this object using the key
image%2Bexample.jpg instead of
image+example.jpg from your S3 bucket, hence resulting in a valid response.
If you have a mix of the two kinds of keys in your S3 bucket, with and without encoded characters, then you can add two origins to your ImageKit account, one having encoding enabled & another with encoding disabled. Map these two to the same URL endpoint. This way, ImageKit will attempt to get the same object from with both the variations, once with encoded key name and once with the regular key name.
We have added a few examples for you to understand how different special characters present in your URL are fetched from ImageKit.
In case you need this feature enabled for your account, kindly create a support ticket from your ImageKit dashboard & our team will enable it for you.
For any other queries, kindly send an email to email@example.com