Created
November 22, 2021 19:19
-
-
Save toast38coza/9c77a1177c0cb222c449f47814d7a880 to your computer and use it in GitHub Desktop.
Manually upload a file to imagekit using python requests
This file contains 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
imagekit_private_key = '..' | |
base = 'https://api.imagekit.io/v1' | |
# files = {"file": result.content} # example from a url | |
files = {"file": open('/some/file.png', 'rb')} # from a local file | |
data = { | |
"fileName": "my-file.png", | |
"tags": "foo,bar,baz", | |
"folder": "/remote/file/path/" | |
} | |
url = f'{base}/files/upload' | |
return requests.post(url, files=files, data=data, auth=(imagekit_private_key, '')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment