2013-07-18 3 views
2

작동하지 않습니다 나는 S3에 내 파일을 업로드 한 코드를 작성하고 그것을 루비으로 잘 작동하지만 난 JRuby를이 같은 오류를주고있다와 같은 파일을 업로드하려고하면 특정 파일을 업로드하는 동안 오류를 얻고있다 - :보석 JRuby를

-> "HTTP/1.1 400 Bad Request\r\n" 
-> "x-amz-request-id: -------------\r\n" 
-> "x-amz-id-2: some_id\r\n" 
-> "Content-Type: application/xml\r\n" 
-> "Transfer-Encoding: chunked\r\n" 
-> "Date: Thu, 18 Jul 2013 05:50:24 GMT\r\n" 
-> "Connection: close\r\n" 
-> "Server: AmazonS3\r\n" 
-> "\r\n" 
-> "15c\r\n" 

여기에 내 코드

# endcoding: UTF-8 

require 'aws-sdk' 
module Upload 
def self.ufile(name) 
    AWS.config(
     access_key_id: 'ACCESS_KEY', 
     secret_access_key: 'SECRET_KEY') 
    s3 = AWS::S3.new(logger: Logger.new($stderr), http_wire_trace: true) 
    bucket = 'bucket_name' 
    base_name = File.basename(name) 
    AWS.config.http_handler.pool.empty! 
    obj = s3.buckets[bucket].objects[base_name].write(File.open(name), content_length: File.size(name)) 
    obj.acl = :public_read_write 
    obj.public_url 
end 
end 

주입니다.

답변

0

당신은 아니 전혀 작동하지 않는

begin 
    do_something 
rescue AWS::Errors::ClientError 
    # rescues all 400 level errors 
end 
+0

구문을 다음과 같이이 문제를 처리 할 수 ​​있습니다. 오류가 있지만 파일을 업로드하지 않는 경우에만 처리됩니다. – Sourabh

+0

구조 요청을 통해 업로드를 다시 시도해야합니다. – Cthulhu