Spaces:
Runtime error
Runtime error
File size: 955 Bytes
11dfac9 8d9048c 11dfac9 8d9048c 11dfac9 bac48a1 11dfac9 8d9048c bac48a1 8d9048c bac48a1 11dfac9 8d9048c 11dfac9 8d9048c 11dfac9 | 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 | import requests
import os
"""
Uploads an image to Placid App and returns the URL of the processed image.
Parameters:
- api_key (str): Your Placid API key.
- image_path (str): The file path to the image you want to upload.
Returns:
- str: URL of the processed image.
"""
api_key = "placid-jza5wyzybmjyf0oe-rponxsufgssdygqk"
def uploadImages(image_files):
files = []
for index, file_tuple in enumerate(image_files):
file_path = file_tuple[0]
# Open the file in binary mode and include it in the list
files.append(('file'+str(index), (file_path, open(file_path, 'rb'), 'image/png')))
url = "https://api.placid.app/api/rest/media"
headers = {
"Authorization": f"Bearer {api_key}"
}
response = requests.post(url, headers=headers, files=files)
print(response)
data = response.json()
file_urls = [item["file_id"] for item in data["media"]]
print(data)
return file_urls |