forked from gegendepressed/OpenMedia
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfileupload.py
More file actions
29 lines (22 loc) · 747 Bytes
/
fileupload.py
File metadata and controls
29 lines (22 loc) · 747 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import cloudinary
from cloudinary import CloudinaryImage
import cloudinary.uploader
import cloudinary.api
from os import environ
cloudinary.config(
cloud_name = environ.get("CLOUDINARY_NAME"),
api_key = environ.get("CLOUDINARY_KEY"),
api_secret = environ.get("CLOUDINARY_SECRET"),
secure=True
)
def upload_image(file_object, filename):
cloudinary.uploader.upload(file_object,
public_id=filename,
unique_filename=False,
overwrite=True)
src_url = CloudinaryImage(filename).build_url()
return src_url
def delete_image(filename):
cloudinary.uploader.destroy(filename)
if __name__ == "__main__":
delete_image("yash_pfp")