29 lines
731 B
Python
29 lines
731 B
Python
from minio import Minio
|
|
from os import getenv
|
|
import json
|
|
import io
|
|
|
|
print("---")
|
|
print(getenv("S3_ENDPOINT"),
|
|
getenv("S3_ACCESS_KEY"),
|
|
getenv("S3_SECRET_KEY"),
|
|
json.loads(getenv("S3_IS_SECURE", "false")), sep="\n"
|
|
)
|
|
print("---")
|
|
|
|
client = Minio(
|
|
getenv("S3_ENDPOINT"),
|
|
access_key=getenv("S3_ACCESS_KEY"),
|
|
secret_key=getenv("S3_SECRET_KEY"),
|
|
secure=json.loads(getenv("S3_IS_SECURE", "false")),
|
|
)
|
|
|
|
ThumbsBucket = "iwm-user-thumbnails"
|
|
|
|
if not client.bucket_exists(ThumbsBucket):
|
|
client.make_bucket(ThumbsBucket)
|
|
|
|
async def upload_thumbnail(data, levelID):
|
|
# file = io.BytesIO(await data.read())
|
|
client.put_object(ThumbsBucket, f"{levelID}.png", data.file, length=-1, part_size=10*1024*1024)
|
|
|