首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >错误18:无效的跨设备链接

错误18:无效的跨设备链接
EN

Stack Overflow用户
提问于 2016-08-11 08:00:07
回答 1查看 5K关注 0票数 1

我在amazon lambda上写了一个函数,并写了下面的脚本,但我得到了一个错误。只要将对象放入S3存储桶中,脚本就会运行。

代码语言:javascript
复制
s3 = boto3.client('s3')

def lambda_handler(event, context):
    path = '/tmp/videos'
    if not os.path.exists(path):
        os.makedirs(path)
    for record in event['Records']:
        bucket = record['s3']['bucket']['name']
        key = record['s3']['object']['key'] 
        try:
            response = s3.get_object(Bucket=bucket, Key=key)
            print("CONTENT TYPE: " + response['ContentType'])
            video_path = '/tmp/{}'.format(key)
            download_path = '/tmp/'
            print('video path: ' + video_path)
            print('download path: ' + download_path)
            print('key: ' + key)
            print('bucket: ' + bucket)
            s3.download_file(bucket, key, download_path)
        except Exception as e:
            print(e)
            print('Error getting object {} from bucket {}. Make sure they exist and your bucket is in the same region as this function.'.format(key, bucket))
            raise e

我测试了这个函数,得到了以下输出:

代码语言:javascript
复制
START RequestId: aa42300f-5f52-11e6-a14e-a3511b08d368 Version: $LATEST
CONTENT TYPE: video/mp4
video path: /tmp/videos/20160810-182413-jjrni-capturedvideo.mp4
download path: /tmp/
key: videos/20160810-182413-jjrni-capturedvideo.mp4
bucket: bucket
[Errno 18] Invalid cross-device link
Error getting object videos/20160810-182413-jjrni-capturedvideo.mp4 from bucket bucket. Make sure they exist and your bucket is in the same region as this function.
[Errno 18] Invalid cross-device link: OSError
Traceback (most recent call last):
  File "/var/task/CreateThumbnail.py", line 48, in lambda_handler
    raise e
OSError: [Errno 18] Invalid cross-device link
END RequestId: aa42300f-5f52-11e6-a14e-a3511b08d368

错误来自:

代码语言:javascript
复制
s3.download_file(bucket, key, download_path)

我不确定为什么当s3可以从以下位置检索密钥和存储桶时,下载文件时会出现错误:

代码语言:javascript
复制
response = s3.get_object(Bucket=bucket, Key=key)

如有任何帮助,我们不胜感激!( S3存储桶采用美国标准,我认为是US-East1,而Lambda函数采用US-N。弗吉尼亚州)

EN

回答 1

Stack Overflow用户

发布于 2016-08-11 10:13:21

您的问题看起来类似于这个https://github.com/amorton/cassback/issues/2

从/tmp构建相对路径而不是文件怎么样?

还有,为什么你需要把文件放到服务器上?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38885346

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档