![](/img/trans.png)
[英]Getting error with subprocess while running aws s3 cp: [Errno 2] No such file or directory: 'aws'
[英]Getting error while Generating Thumbnail of Image in aws s3
当我将图像上传到直接 Backet 时,它工作正常,但如果文件夹出错
Line=> s3_client.download_file(bucket, key, download_path)
下载路径。
for record in event['Records']:
bucket = record['s3']['bucket']['name']
key = record['s3']['object']['key']
download_path = '/tmp/{}{}'.format(uuid.uuid4(), key)
upload_path = '/tmp/resized-{}'.format(key)
print('Bucket Path', bucket)
print('Key path', key)
print('Download path', download_path)
print('Upload path', upload_path)
s3_client.download_file(bucket, key, download_path)
resize_image(download_path, upload_path)
s3_client.upload_file(upload_path, '{}-resized'.format(bucket), key)
您似乎正在使用来自示例 Amazon S3 function 代码 - AWS Lambda 的代码。
该代码有一个额外的行删除斜杠:
for record in event['Records']:
bucket = record['s3']['bucket']['name']
key = unquote_plus(record['s3']['object']['key'])
tmpkey = key.replace('/', '') # <--- This line here!
download_path = '/tmp/{}{}'.format(uuid.uuid4(), tmpkey) # <--- Used here
upload_path = '/tmp/resized-{}'.format(tmpkey)
s3_client.download_file(bucket, key, download_path)
resize_image(download_path, upload_path)
s3_client.upload_file(upload_path, '{}-resized'.format(bucket), key)
这允许 Python 存储文件,而无需创建分层目录。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.