s3 分段下载核心原理-获取指定范围的文件内容

为什么80%的码农都做不了架构师?>>>   hot3.png

from boto.s3.connection import S3Connection
import boto

access_key = 'access_key'
secret_key = 'secret_key'
host = 'xxx'
bucket = 'g3test1'
object = 'hello.lua'
tmpfile = '/tmp/file1'

conn = S3Connection(access_key, secret_key, host=host, is_secure=False)

conn = boto.connect_s3(
        aws_access_key_id = access_key,
        aws_secret_access_key = secret_key,
        host = host,
        is_secure=False,
        calling_format = boto.s3.connection.OrdinaryCallingFormat(),
        validate_certs = True,
        )
bucket = conn.get_bucket(bucket)
key= bucket.get_key(object)
key.get_contents_to_filename(tmpfile,headers={'Range': 'bytes=0-100'})

转载于:https://my.oschina.net/diluga/blog/611419

你可能感兴趣的:(s3 分段下载核心原理-获取指定范围的文件内容)