【发布时间】:2019-06-07 11:53:37
【问题描述】:
我正在尝试使用 GC 函数(相当于 AWS Lambda)将文件从 GCS 移动到 s3 存储桶。为了实现它,我尝试了 3 种不同的方法。在方法 1 中我得到错误,而在其他 2 个选项中我没有得到错误,文件实际上没有被复制过来。
有人可以帮忙吗?
另外两种方法都标有#,我已经分别尝试过。
s3_client.upload_file 不起作用,因为它需要源文件的路径,当我提供“gs://
'不存在这样的文件或目录'
gustil 命令正确执行,没有错误,但在 s3 存储桶中没有创建新文件。
import os
from google.cloud import storage
import boto3
import subprocess
s3_client=boto3.client('s3',aws_access_key_id='XYZ',aws_secret_access_key='ABC')
client = storage.Client()
def hello_gcs(data, context):
bucket = client.get_bucket(data['bucket'])
blob = bucket.blob(data['name'])
#subprocess.call(['gsutil -m rsync -r gs://<google_bucket_name>/30327570.pdf s3://<aws_bucket_name>'], shell=True)
subprocess.call(['gsutil cp gs://<google_bucket_name>/30327570.pdf s3://<aws_bucket_name>'], shell=True)
#s3_client.upload_file('gs://<google_bucket_name>/30327570.pdf','<aws_bucket_name>','30327570.pdf')
【问题讨论】:
标签: python amazon-s3 google-cloud-platform google-cloud-storage google-cloud-functions