Access to images from s3 in case of insensitivity

I used the expression in node.js, where it served static images in a case-insensitive manner, but when I switched to s3, I found that the images were case-sensitive.

Is there any way in amazon s3 to serve static files (images) in a case-insensitive manner? any configuration? otherwise, the best option would be to convert the images to lowercase before putting them into s3.

UPDATE

Another problem is C ++. jpg s3 is not displayed, it needs to be converted to c% 2B% 2B.jpg. Whereas C ++. A jpg renders like a charm. Is there any workaround here?

+6
source share
3 answers

No, S3 file names are case sensitive. Presumably this is a limitation of the linux / unix base file system.

I always recommend people upload only lowercase file names.

+12
source

Whenever you upload a file to S3, you create a URL. To ensure that you are safe, you can evaluate the file names that you use. The RFC-Som specification for HTTP URLs allows the following characters to be within URLs.

RegEx

[a-zA-Z0-9_-]+ 

Any file name that does not match this pattern that you might want to change to be URL compatible. AWS is CasE-SensITive, primarily because it is designed as a store object. When saving objects. Many times, objects that are written are saved using a Base64 URL encoded Safe encoded hash to create a more reliable search time for objects during retrieval.

0
source

It should also be noted that S3 is designed for access via HTTP (S). HTTP URLs are case sensitive. Servers that allow case-insensitive URL access are broken because they can pollute caches. The image.jpg , image.jpg , image.jpg can point to the same file, but the cache will not know and download the same file several times. The same goes for the web browser. If you image.jpg twice to one image on a page as soon as image.jpg and once as image.jpg , the browser will download the image twice. Therefore, it makes no sense to require that S3 not be case sensitive. Instead, stick to the fact that the RFCs about URLs and HTTP speak and correct your site.

By the way, regardless of whether the storage of basic objects is implemented on POSIX (Unix, Linux) or Windows, this is not important for this question, it is about the HTTP and URL specifications (RFC).

0
source

Source: https://habr.com/ru/post/909880/


All Articles