2014-11-07 6 views
6

내가 boto에 파일을 업로드하려고 해요,boto로 파일을 업로드 할 때 왜 400이 나오나요?

import io 

from boto.s3 import connection 
from boto.s3 import key 

conn = connection.S3Connection() 
bucket = conn.get_bucket('my-bucket') 

my_key = key.Key(bucket, 'asdf') 

d = b'this is a test....\n' * 512000 
f = io.BytesIO(d) 

my_key.send_file(f, size=4*1024) 

그러나,이 결과 :

boto.exception.S3ResponseError: S3ResponseError: 400 Bad Request 
<?xml version="1.0" encoding="UTF-8"?><Error><Code>BadRequest</Code><Message>An error occurred when parsing the HTTP request.</Message><RequestId>[hex request ID]</RequestId><HostId>[giant piece of base64]</HostId></Error> 

는 왜 요청이 실패?

(참고 : open 분명히에만 ... 읽기 지원하기 때문에 내가 여기 send_file를 사용하고 전체 이유는) set_contents_from_file()send_file()를 교체, 그것은 가치가 무엇인지에 대한

+0

''my_key.set_contents_from_file (f)''하면 어떻게됩니까? 같은 오류가 발생합니까? – garnaat

+0

@ garnaat 호출이 성공합니다. 요점은'boto'가 전체 파일을 메모리로 읽어 들이지 않도록하는 것입니다. size 인수를 추가하면'set_contents_from_file'은 첫 번째'size' 바이트 만 읽습니다. (어떤 기능이 그 기능을 수행 할 것이라고하지만, 내가 뭘 원하는지 않습니다.) – Thanatos

+0

그것은 진정한 스트리밍 원하는 정말 들리지만 불행히도 S3 지원하지 않습니다. 적어도 아직은. – garnaat

답변

4

(I 같은 오류를했다) 날 위해 일했습니다.