import boto3
S3API = boto3.client("s3", region_name="us-east-1")
S3API.**<FMI>**(Bucket="tiwaladebucket")
import boto3
S3API = boto3.client("s3", region_name="us-east-1")
bucket_name = "tiwaladebucketcatfound"
filename = "../cat.jpg"
S3API.**<FMI>**(filename, tiwaladebucketcatfound, "cat.jpg", ExtraArgs={'**<FMI>**': "image/jpg", "CacheControl": "max-age=0"})
filename = "../index.html"
S3API.**<FMI>**(filename, tiwaladebucketcatfound, "**<FMI>**", ExtraArgs={'ContentType': "text/html", "CacheControl": "max-age=0"})发布于 2021-09-29 06:22:15
您是s3客户端,需要使用put_object接口上传文件到S3
S3API.put_object(Body=binary_data, Bucket='my_bucket_name', Key='s3folder/path/filename.txt')
or
S3API.put_object(Body=file_object, Bucket='my_bucket_name', Key='s3folder/path/filename.txt')或者,您也可以使用S3资源而不是S3客户端来执行相同操作
s3_resource = boto3.resource('s3')
s3_resource.Bucket('bucketname').upload_file('/local/file/a.txt','folder/path/to/s3key')发布于 2021-09-29 06:34:10
有多个FMI,正如我所看到的,它们不能被相同的命令替换。更多关于代码尝试的信息会更好,但我猜你想要:
创建存储桶"iwaladebucket"
使用上面的代码,下面的代码将实现这一点:
import boto3
s3client = boto3.client("s3", region_name="us-east-1")
s3client.create_bucket(Bucket="tiwaladebucket")
bucket_name = "tiwaladebucket"
filename = "../cat.jpg"
s3client.put_object(filename, bucket_name, "cat.jpg", ExtraArgs={'ContentType': "image/jpg", "CacheControl": "max-age=0"})
filename = "../index.html"
s3client.put_object(filename, bucket_name, "index.html", ExtraArgs={'ContentType': "text/html", "CacheControl": "max-age=0"})https://stackoverflow.com/questions/69370281
复制相似问题