2014-12-18 2 views
-2

boto 클라이언트를 사용하여 s3에 파일을 다운로드하고 업로드하고 한 폴더 키에서 다른 폴더 키로 복사하는 등의 작업을 수행하고 있습니다. 크기를 키 복사하려고 할 때 문제가 발생합니다. 0 바이트입니다. 내가 복사하기 위해 사용하는 코드는boto를 통해 다운로드

# Get the connection to the bucket 
conn = boto.connect_s3(AWS_KEY, SECRET_KEY) 
bucket = conn.get_bucket('mybucket') 

# bucket.name is the name of my bucket 
# candidate is the source key 
destination_key = "destination/path/on/s3" 
candidate = "the/file/to/copy" 

# now copy the key 
bucket.copy_key(destination_key, bucket.name, candidate) # --> This throws an exception 

# just in case, see if the key ended up in the destination. 
copied_key = bucket.lookup(destination_key) 

내가

3ResponseError: 404 Not Found 
<Error><Code>NoSuchKey</Code> 
    <Message>The specified key does not exist.</Message> 
    <Key>the/file/to/copy</Key><RequestId>ABC123</RequestId><HostId>XYZ123</HostId> 
</Error> 

지금은 키 가리키고는 AWS 콘솔에 로그인 한 후 소스 키를 탐색하여 존재하는 것을 확인 한 것입니다 얻을 예외 이하 위치에 키가 있고 aws 콘솔에 크기가 0 인 것으로 표시됩니다 (응용 프로그램에 빈 파일로 끝날 수 있지만 s3에 필요함).

그래서 업로드 BOTO은 어떤 문제없이 키를 업로드, 잘 작동하지만 내가 그것을 복사하려고 할 때, 나는 그래서 내가 있어야 할 다른 논리가 키가

존재하지 않는다는 오류 이러한 키를 복사하는 데 사용 하시겠습니까? 이와 관련하여 도움이된다면

답변

0

소스 키의 버킷을 포함시켜야합니다. 해야 bucket/path/to/file/to/copy

+0

감사합니다, 그래, 난 이미 연결이 이루어질 때 그 일을했다. 내 대답을 편집하여 연결 방법을 보여줍니다. –

0

같은이 시도 : 응답에 대한

from boto.s3.key import Key 
download_path = '/tmp/dest_test.jpg' 
bucket_key = Key(bucket) 
bucket_key.key = file_key # e.g. images/source_test.jpg 
bucket_key.get_contents_to_filename(download_path) 
관련 문제