title: Errno 18: Invalid cross-device link
body: <p>I am writing a function on amazon lambda and wrote the script below, but I'm getting an error. The script runs whenever an object is put into an S3 Bucket. </p>
  
  <pre><code>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
  </code></pre>
  
  <p>I tested the function and got the following output:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>The error is coming from:</p>
  
  <pre><code>s3.download_file(bucket, key, download_path)
  </code></pre>
  
  <p>I'm not sure why there is an error downloading the file when s3 can retrieve the key and bucket from: </p>
  
  <pre><code>response = s3.get_object(Bucket=bucket, Key=key)
  </code></pre>
  
  <p>Any help is appreciated!
  (The S3 bucket is in US Standard, which I think is US-East1, and the Lambda function is in US-N. Virginia)</p>