Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services 如何使用boto3写入S3标准不频繁访问?_Amazon Web Services_Amazon S3_Boto3 - Fatal编程技术网

Amazon web services 如何使用boto3写入S3标准不频繁访问?

Amazon web services 如何使用boto3写入S3标准不频繁访问?,amazon-web-services,amazon-s3,boto3,Amazon Web Services,Amazon S3,Boto3,我在网上搜索,但没有找到相关信息。在本文中,提到可以使用 k.storage\u class='STANDARD\u IA' 有人能在这里分享完整的代码片段吗?非常感谢。从这个示例来看,将对象放入bot3的标准方法是 s3.Object('mybucket', 'hello.txt').put(Body=open('/tmp/hello.txt', 'rb')) 但要设置存储类,建议使用参数: StorageClass='STANDARD_IA' 因此,将两者结合起来,我们有: import

我在网上搜索,但没有找到相关信息。在本文中,提到可以使用

k.storage\u class='STANDARD\u IA'

有人能在这里分享完整的代码片段吗?非常感谢。

从这个示例来看,将对象放入
bot3
的标准方法是

s3.Object('mybucket', 'hello.txt').put(Body=open('/tmp/hello.txt', 'rb'))
但要设置存储类,建议使用参数:

StorageClass='STANDARD_IA'
因此,将两者结合起来,我们有:

import boto3
s3 = boto3.resource('s3')
s3.Object('mybucket', 'hello.txt').put(Body=open('/tmp/hello.txt', 'rb'), StorageClass='STANDARD_IA')
希望这对您有所帮助,从这个示例来看,将对象放入
bot3
的标准方法是

s3.Object('mybucket', 'hello.txt').put(Body=open('/tmp/hello.txt', 'rb'))
但要设置存储类,建议使用参数:

StorageClass='STANDARD_IA'
因此,将两者结合起来,我们有:

import boto3
s3 = boto3.resource('s3')
s3.Object('mybucket', 'hello.txt').put(Body=open('/tmp/hello.txt', 'rb'), StorageClass='STANDARD_IA')

希望对新文件有所帮助

import boto3

client = boto3.client('s3')

client.upload_file(
    Filename = '/tmp/foo.txt', 
    Bucket = 'my-bucket', 
    Key = 'foo.txt',
    ExtraArgs = {
      'StorageClass': 'STANDARD_IA'
    }
)
现有文件

import boto3

client = boto3.client('s3')

client.upload_file(
    Filename = '/tmp/foo.txt', 
    Bucket = 'my-bucket', 
    Key = 'foo.txt',
    ExtraArgs = {
      'StorageClass': 'STANDARD_IA'
    }
)
发件人:


新文件

import boto3

client = boto3.client('s3')

client.upload_file(
    Filename = '/tmp/foo.txt', 
    Bucket = 'my-bucket', 
    Key = 'foo.txt',
    ExtraArgs = {
      'StorageClass': 'STANDARD_IA'
    }
)
现有文件

import boto3

client = boto3.client('s3')

client.upload_file(
    Filename = '/tmp/foo.txt', 
    Bucket = 'my-bucket', 
    Key = 'foo.txt',
    ExtraArgs = {
      'StorageClass': 'STANDARD_IA'
    }
)
发件人:


是否希望在创建对象时或创建对象后设置该存储类?是否可以双向显示?是否希望在创建对象时或创建对象后设置该存储类?是否可以双向显示?