Post linked images, even when their URL doesn't end in the pre-defined whitelist of extensions
This can be accomplished by making an HTTP HEAD
(info about HEAD) request to the URL and seeing if the Content-Type
header (MIME type) returned is a known image type.
Some notes when you go to implement:
- Mozilla has a nice list of MIME types that are images.
- I suspect Signal won't render SVGs when sent. This should be researched (eg send one and see what happens). If they don't render SVGs, just ignore SVGs initially and add another feature where it renders the SVG to a bitmap format (eg png). Please let me know if Signals supports SVG, some lulz may be possible if they do.
- The
requests
library can make HTTPHEAD
requests, which returns aResponse
object that has aheaders
property. Sample code, ripped almost directly from the Requests homepage: ```
r = requests.head('https://api.github.com/user') r.status_code 200 r.headers['content-type'] 'application/json; charset=utf8'