У меня есть самостоятельный Minio. < /p>
Проблема: невозможно загрузить файлы .csv и .jpg. Способен загрузить файлы .txt и .md. < /P>
это странно, и я вбивал голову. , в значительной степени открыта для любых операций. Чтобы загрузить любой тип файла через веб -портал. Невозможно загрузить файлы .csv, .jpg и .tar программно. Работает только для файлов .md и .txt. < /P>
Я попытался программно загружать, а затем загружать из того же ключа доступа, не работает. Работает только для файлов .md и .txt. < /P>
Я в конце концов. Был в этом часами, больше не могу принять это. Исчерпал всю помощь Catgpt. Stackoverflow - моя последняя попытка - поверьте мне, я бы предпочел быть в другом месте. < /P>
код: < /p>
class MinioUploader:
def __init__(self):
self.minioClient = Minio(
endpoint="myminio.website.com",
region="us-east-1",
access_key="myaccesskeywhichiwillnotputhere",
secret_key="mysecretketywhichiwillnotputhere",
secure=True
)
def download_all_files(self, bucket_name, local_path="./storage/local_storage/"):
if self.minioClient is None:
logs_sys.error("Minio client is not initialized.")
return
if not self.minioClient.bucket_exists(bucket_name):
logs_sys.error(f"Bucket: {bucket_name} does not exist")
return
local_path = os.path.join(local_path, bucket_name)
if not os.path.exists(local_path):
os.makedirs(local_path)
print(f"local_path: {local_path}")
objects = self.minioClient.list_objects(bucket_name, recursive=True)
for obj in objects:
try:
print(obj.object_name)
# Decode any percent-encoded characters in the object name
decoded_object_name = unquote(obj.object_name)
# Create a safe, absolute file path
safe_local_path = os.path.join(local_path, *decoded_object_name.split('/'))
# Ensure the directory for the file exists
safe_local_path = safe_local_path.replace("\\", "/")
os.makedirs(os.path.dirname(safe_local_path), exist_ok=True)
# Download the object
print(f"Downloading {obj.object_name} to {safe_local_path}")
self.minioClient.fget_object(bucket_name=bucket_name, object_name=obj.object_name, file_path=safe_local_path)
except Exception as e:
logs_sys.error(f"Error: {e}")
print(f"Error: {e}")
< /code>
print out: < /p>
D:\TRADING_RESTORE_STRATEGIES>python -u "d:\TRADING_RESTORE_STRATEGIES\storage\minio_s3\minio_client.py"
local_path: ./storage/local_storage/testdownloadbucket
11.md
Downloading 11.md to ./storage/local_storage/testdownloadbucket/11.md
3-7-2024 3-11-49 AM.jpg
Downloading 3-7-2024 3-11-49 AM.jpg to ./storage/local_storage/testdownloadbucket/3-7-2024 3-11-49 AM.jpg
Error: S3 operation failed; code: AccessDenied, message: Access denied, resource: /testdownloadbucket/3-7-2024%203-11-49%20AM.jpg, request_id:
17BACF23766A4250, host_id: dd9025af9251148b658df7ac2e3e8, bucket_name: testdownloadbucket, object_name: 3-
7-2024 3-11-49 AM.jpg
asad.txt
Downloading asad.txt to ./storage/local_storage/testdownloadbucket/asad.txt
new.csv
Downloading new.csv to ./storage/local_storage/testdownloadbucket/new.csv
Error: S3 operation failed; code: AccessDenied, message: Access denied, resource: /testdownloadbucket/new.csv, request_id: 17BACF23839DECB7, h
ost_id: dd9025af9251148b658df7ac2e3e8, bucket_name: testdownloadbucket, object_name: new.csv
something1.csv
Downloading something1.csv to ./storage/local_storage/testdownloadbucket/something1.csv
Error: S3 operation failed; code: AccessDenied, message: Access denied, resource: /testdownloadbucket/something1.csv, request_id: 17BACF238744
C16C, host_id: dd9025af9251148b658df7ac2e3e8, bucket_name: testdownloadbucket, object_name: something1.csv
test.txt
Downloading test.txt to ./storage/local_storage/testdownloadbucket/test.txt
Подробнее здесь: https://stackoverflow.com/questions/781 ... file-types