-
Notifications
You must be signed in to change notification settings - Fork 4
/
my_file.py
44 lines (32 loc) · 1.39 KB
/
my_file.py
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Set your Cloudinary credentials
# ==============================
import json
import cloudinary.api
import cloudinary.uploader
import cloudinary
from dotenv import read_dotenv
read_dotenv()
# Import the Cloudinary libraries
# ==============================
# Import to format the JSON responses
# ==============================
# Set configuration parameter: return "https" URLs by setting secure=True
# ==============================
config = cloudinary.config(secure=True)
# Log the configuration
# ==============================
print("****1. Set up and configure the SDK:****\nCredentials: ",
config.cloud_name, config.api_key, "\n")
def uploadImage():
# Upload the image and get its URL
# ==============================
# Upload the image.
# Set the asset's public ID and allow overwriting the asset with new versions
cloudinary.uploader.upload("https://cloudinary-devs.github.io/cld-docs-assets/assets/images/butterfly.jpeg",
public_id="quickstart_butterfly", unique_filename=False, overwrite=True)
# Build the URL for the image and save it in the variable 'srcURL's
srcURL = cloudinary.CloudinaryImage("quickstart_butterfly").build_url()
# Log the image URL to the console.
# Copy this URL in a browser tab to generate the image on the fly.
print("****2. Upload an image****\nDelivery URL: ", srcURL, "\n")
# uploadImage()