1
아마존 람다에 함수를 쓰고 아래 스크립트를 작성했지만 오류가 발생했습니다. 이 스크립트는 객체가 S3 버킷에 배치 될 때마다 실행됩니다.Errno 18 : 유효하지 않은 교차 장치 링크
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
나는 기능을 시험하고 다음과 같은 출력 있어요 : 파일을 다운로드 오류가 발생하는 이유는 확실하지 않다
s3.download_file(bucket, key, download_path)
:
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
이 오류에서 오는됩니다 s3에서 키와 버킷을 검색 할 수있는 경우 :
도움을 주시면 감사하겠습니다! 합니다 (S3 버킷 내가 미국 East1 생각 미국 표준이며, 람다 함수가 US-N입니다. 버지니아)
비디오가 S3 버킷에 업로드 될 때마다 스크립트를 실행해야합니다. 파이썬 섹션에서이 튜토리얼의 코드를 따랐다 : [aws lambda python example] (http://docs.aws.amazon.com/lambda/latest/dg/with-s3-example-deployment-pkg.html) 그리고/tmp에있는 파일의 경로를 사용했습니다. – alienboy