简体   繁体   English

是否可以将文件从 URL 部分上传到 S3? 文件.aa、文件.ab、文件.ac

[英]is it possible to upload a file to S3 from a URL in parts? file.aa, file.ab, file.ac

i would like to upload a really large file 3TB from a URL to s3 directly, but want to upload it in parts, similar to if i would split the file on my machine and upload the parts to s3.我想将一个非常大的文件 3TB 从 URL 直接上传到 s3,但想分部分上传,类似于我在我的机器上拆分文件并将部分上传到 s3。

I have the following script to upload the file (whole) from url to S3, how can i modify it to upload it to (parts) file.aa, file.ab, file.ac etc..我有以下脚本将文件(整个)从 url 上传到 S3,我该如何修改它以将其上传到(部分)file.aa、file.ab、file.ac 等。

import requests
import boto3

url = "https://example.com/file.tar"
r = requests.get(url, stream=True)

session = boto3.Session()
s3 = session.resource('s3')

bucket_name = 'bucket-name'
key = 'file.tar' # key is the name of file on your bucket

bucket = s3.Bucket(bucket_name)
bucket.upload_fileobj(r.raw, key)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM