Spaces:
Sleeping
Sleeping
| import cloudinary | |
| import cloudinary.uploader | |
| from config import config | |
| from config.config import CLOUDINARY_CLOUD_NAME, CLOUDINARY_API_KEY, CLOUDINARY_API_SECRET | |
| print("π Cloudinary setup successful", CLOUDINARY_CLOUD_NAME) | |
| cloudinary.config( | |
| cloud_name=CLOUDINARY_CLOUD_NAME, | |
| api_key=CLOUDINARY_API_KEY, | |
| api_secret=CLOUDINARY_API_SECRET | |
| ) | |
| def upload_to_cloudinary(image_path): | |
| """Upload a single image to Cloudinary within the 'image_search' folder""" | |
| response = cloudinary.uploader.upload( | |
| image_path, | |
| folder="image_search" # Specify the folder name | |
| ) | |
| return response["secure_url"] | |
| def upload_multiple_to_cloudinary(image_paths): | |
| """Upload multiple images to Cloudinary within the 'image_search' folder and return array of URLs""" | |
| urls = [] | |
| for path in image_paths: | |
| url = upload_to_cloudinary(path) # The folder is already handled in upload_to_cloudinary | |
| urls.append(url) | |
| return urls |