Skip to content

Handling MIME Types When Asset URL Extensions and Actual Entities Mismatch in HTMLReader._adownload_direct_linked_file #5

@jun76

Description

@jun76
# FIXME:
# Bedrock's MIME type check is strict, and if the MIME type you specified
# is incorrect, it returns the following error:
#
#  An error occurred (ValidationException) when calling the InvokeModel
#  operation: The detected file MIME type image/png does not match the
#  expected type image/webp. Reformat your input and try again.
#
# Therefore, if the target URL is misleading (e.g., the URL specifies
# .webp but the actual content is png), we must inspect the magic numbers
# within the binary. However, since other providers do not require MIME
# types in the first place and still succeed in embedding, we will treat
# the URL as valid as before (even if the actual content differs) and
# ignore this error.
ext = Exts.get_ext(url)
path = get_temp_file_path_from(source=url, suffix=ext)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions