Skip to content

The first 3 bytes determine whether the file is a .jpeg file #429

@senk8

Description

@senk8

Is your feature request related to a problem? Please describe.
Hello! When I was using the serverless-image-handler, I could not view files with a specific magic number (i.e. FFD8FFED).
This line seems to be the cause.
https://github.com/aws-solutions/serverless-image-handler/blob/develop/source/image-handler/image-request.ts#L441

To Reproduce
Place a file with magic number FFD8FFED in your S3 bucket and specify application/octet-stream for Content-Type.

The following error occurs.

{"status":500,"code":"RequestTypeError","message":"The file does not have an extension and the file type could not be inferred. Please ensure that your original image is of a supported file type (jpg, png, tiff, webp, svg). Refer to the documentation for additional guidance on forming image requests."}

Describe the feature you'd like

Can I make it so that only jpeg files use the first 3 bytes (FFD8FF) to determine the extension? Although there are almost no JPEG files with magic numbers that do not match a switch statement such as FFD8FFED, the first 3 bytes seem to be appropriate for determining 'image/jpeg'.

Best regards.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions