Skip to content

Instantly share code, notes, and snippets.

@toast38coza
Created November 22, 2021 19:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toast38coza/9c77a1177c0cb222c449f47814d7a880 to your computer and use it in GitHub Desktop.
Save toast38coza/9c77a1177c0cb222c449f47814d7a880 to your computer and use it in GitHub Desktop.
Manually upload a file to imagekit using python requests
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