1

私はamazon lambdaに関数を書いていて、以下のスクリプトを書いていますが、エラーが発生しています。このスクリプトは、オブジェクトが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 

私は、機能をテストし、次の出力を得た:

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.download_file(bucket, key, download_path) 

私はわからないんだけどs3がキーとバケットを取得できるときは、

ご迷惑をおかけして申し訳ございません。 (S3バケットは、私が米国East1だと思う米国標準であり、かつラムダ関数は米国-Nである。バージニア州)は

答えて

0

あなたの問題は、この1 https://github.com/amorton/cassback/issues/2

に似ていますどのように相対的な構築について/ tmpからのファイルの代わりにパス?

また、なぜファイルをサーバーに取得する必要がありますか?

+0

動画がS3バケットにアップロードされるたびにスクリプトを実行する必要があります。私はこのチュートリアルのコードをPythonのセクションで説明しました:[aws lambda python example](http://docs.aws.amazon.com/lambda/latest/dg/with-s3-example-deployment-pkg.html)彼らは/ tmpからのファイルのパスを使いました – alienboy

関連する問題