-
-
Save KyMidd/e466ee540b161e138d1522ae726843c1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Check the mime type of the file is a supported image file type | |
| if file["mimetype"] in [ | |
| "image/png", # png | |
| "image/jpeg", # jpeg | |
| "image/gif", # gif | |
| "image/webp", # webp | |
| ]: | |
| # Isolate the file type based on the mimetype | |
| file_type = file["mimetype"].split("/")[1] | |
| # Append the file to the content array | |
| content.append( | |
| { | |
| "image": { | |
| "format": file_type, | |
| "source": { | |
| "bytes": file_content, | |
| } | |
| } | |
| } | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment