提问人:forestbat 提问时间:11/3/2023 更新时间:11/6/2023 访问量:22
为什么从本地机器上传到minio服务器时会出现“权限被拒绝”?
Why there is 'Permission denied‘ when upload from local machine to minio server?
问:
这是我的代码:
# client: Minio
# upload local file in file_path to the minio server
client.fput_object(bucket_name, object_name, file_path)
但是当我运行代码时,它崩溃了,我确定发生“权限被拒绝”的目录的所有者是我,并且我已经以管理员权限运行:pycharm64.exe
..\hydroprivatedata\minio_api.py:29: in minio_upload_csv
client.fput_object(bucket_name, object_name, file_path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <minio.api.Minio object at 0x000001FC32B9A3E0>
bucket_name = 'forestbat-private', object_name = 'driver_data_site24.csv'
file_path = 'C:\\Users\\Administrator\\.hydrodataset\\cache\\forestbat_test'
content_type = 'application/octet-stream', metadata = None, sse = None
progress = None, part_size = 0, num_parallel_uploads = 3, tags = None
retention = None, legal_hold = False
def fput_object(self, bucket_name, object_name, file_path,
content_type="application/octet-stream",
metadata=None, sse=None, progress=None,
part_size=0, num_parallel_uploads=3,
tags=None, retention=None, legal_hold=False):
"""
Uploads data from a file to an object in a bucket.
:param bucket_name: Name of the bucket.
:param object_name: Object name in the bucket.
:param file_path: Name of file to upload.
:param content_type: Content type of the object.
:param metadata: Any additional metadata to be uploaded along
with your PUT request.
:param sse: Server-side encryption.
:param progress: A progress object
:param part_size: Multipart part size
:param num_parallel_uploads: Number of parallel uploads.
:param tags: :class:`Tags` for the object.
:param retention: :class:`Retention` configuration object.
:param legal_hold: Flag to set legal hold for the object.
:return: :class:`ObjectWriteResult` object.
Example::
# Upload data.
result = client.fput_object(
"my-bucket", "my-object", "my-filename",
)
# Upload data with metadata.
result = client.fput_object(
"my-bucket", "my-object", "my-filename",
metadata={"My-Project": "one"},
)
# Upload data with tags, retention and legal-hold.
date = datetime.utcnow().replace(
hour=0, minute=0, second=0, microsecond=0,
) + timedelta(days=30)
tags = Tags(for_object=True)
tags["User"] = "jsmith"
result = client.fput_object(
"my-bucket", "my-object", "my-filename",
tags=tags,
retention=Retention(GOVERNANCE, date),
legal_hold=True,
)
"""
file_size = os.stat(file_path).st_size
> with open(file_path, "rb") as file_data:
E PermissionError: [Errno 13] Permission denied: 'C:\\Users\\Administrator\\.hydrodataset\\cache\\forestbat_test'
..\venv\lib\site-packages\minio\api.py:997: PermissionError
当我将文件从minio服务器下载到本地目录时,它成功了。
那么如何解决这个问题呢?
答:
0赞
agamil
11/6/2023
#1
请确保您具有适当的权限 (WRITE) 将数据上传到存储桶中
要允许存储桶中的上传,您的存储桶策略应授予 s3:PutObject 权限
评论