Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -469,14 +469,15 @@ def post(judul, kontent, gambar, endpoint,endpoint_media,username,password,tags,
|
|
469 |
credentials = base64.b64encode(f"{username}:{password}".encode("utf-8")).decode("utf-8")
|
470 |
headers = {"Authorization": f"Basic {credentials}"}
|
471 |
|
472 |
-
|
473 |
-
|
|
|
474 |
data = {
|
475 |
"alt_text": judul,
|
476 |
"media_type": "image",
|
477 |
"mime_type": "png"
|
478 |
}
|
479 |
-
files = {"file": ("image.jpg",
|
480 |
try :
|
481 |
response_media= requests.post(endpoint_media, headers=headers, data=data, files=files) # Send
|
482 |
|
|
|
469 |
credentials = base64.b64encode(f"{username}:{password}".encode("utf-8")).decode("utf-8")
|
470 |
headers = {"Authorization": f"Basic {credentials}"}
|
471 |
|
472 |
+
gambar_bytes = gambar.tobytes()
|
473 |
+
gambar_base64 = base64.b64encode(gambar_bytes).decode('utf-8')
|
474 |
+
|
475 |
data = {
|
476 |
"alt_text": judul,
|
477 |
"media_type": "image",
|
478 |
"mime_type": "png"
|
479 |
}
|
480 |
+
files = {"file": ("image.jpg", gambar_base64)}
|
481 |
try :
|
482 |
response_media= requests.post(endpoint_media, headers=headers, data=data, files=files) # Send
|
483 |
|