gpt4 book ai didi

python - S3FS python,凭证内联

转载 作者:行者123 更新时间:2023-11-28 22:25:10 24 4
gpt4 key购买 nike

我正在尝试使用 python s3fs 读取 S3 AWS 中的文件。

我找不到将凭据(访问 key + secret )放入 s3fs 代码的代码。

任何人都可以帮助我如何设置此信息以及 s3fs 代码。

import s3fs
fs = s3fs.S3FileSystem(anon=True)

我目前使用的是 Windows 10。

最佳答案

试试下面的

import s3fs
fs = s3fs.S3FileSystem(anon=False, key='<Access Key>', secret='<Secret Key>')

下面是S3FileSystem的参数列表

Parameters
----------
anon : bool (False)
Whether to use anonymous connection (public buckets only). If False,
uses the key/secret given, or boto's credential resolver (environment
variables, config files, EC2 IAM server, in that order)
key : string (None)
If not anonymous, use this access key ID, if specified
secret : string (None)
If not anonymous, use this secret access key, if specified
token : string (None)
If not anonymous, use this security token, if specified
use_ssl : bool (True)
Whether to use SSL in connections to S3; may be faster without, but
insecure
s3_additional_kwargs : dict of parameters that are used when calling s3 api methods.
Typically used for things like "ServerSideEncryption".
client_kwargs : dict of parameters for the boto3 client
requester_pays : bool (False)
If RequesterPays buckets are supported.
default_block_size: None, int
If given, the default block size value used for ``open()``, if no
specific value is given at all time. The built-in default is 5MB.
default_fill_cache : Bool (True)
Whether to use cache filling with open by default. Refer to
``S3File.open``.
config_kwargs : dict of parameters passed to ``botocore.client.Config``
kwargs : other parameters for boto3 session

关于python - S3FS python,凭证内联,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45696635/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com