Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting problem while uploading specific .html to S3 using "gem aws-sdk" #895

Closed
sourabhpataskar opened this issue Jul 18, 2013 · 6 comments

Comments

@sourabhpataskar
Copy link

I wrote one code to upload my file to S3 and it is working fine with RUBY but if I try to upload same file with JRUBY it is giving error as

-> "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"

Here is my code

# 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

NOTE
I am getting error while uploading specific file

@headius
Copy link
Member

headius commented Jul 24, 2013

Can you sniff the request and see what's different?

@headius
Copy link
Member

headius commented Jul 24, 2013

Also... what JRuby version? If not the most recent (or master) you could try updating and see if it is better.

@sourabhpataskar
Copy link
Author

I am using

$ jruby -v
jruby 1.7.3 (1.9.3p385) 2013-02-21 dac429b on Java HotSpot(TM) Client VM 1.7.0_2
5-b17 [Windows 7-x86]

@headius
Copy link
Member

headius commented Jul 24, 2013

Still need more input...try to determine what's different in the request sent with JRuby versus the one Ruby sends.

@kml
Copy link

kml commented Nov 13, 2013

I also have problem with aws-sdk gem and JRuby 1.7.

Body that I'm uploading is string "TEST":

---- JRuby 1.7.6/9000.dev

<- "PUT /**bucket**/url HTTP/1.1\r\nContent-Type: image/jpeg\r\nAccept-Encoding: \r\nContent-Length: 4\r\nX-Amz-Acl: public-read\r\nUser-Agent: aws-sdk-ruby/1.25.0 jruby/1.9.3 java\r\nDate: Wed, 13 Nov 2013 14:15:48 GMT\r\nAuthorization: AWS **cut**\r\nAccept: */*\r\nHost: s3-eu-west-1.amazonaws.com\r\n\r\n"
<- "TEST"

! hanging, never stops

---- JRuby 1.6.7.2

write()
opening connection to s3-eu-west-1.amazonaws.com...
opened
<- "PUT /**bucket**/url HTTP/1.1\r\nContent-Type: image/jpeg\r\nAccept-Encoding: \r\nContent-Length: 4\r\nX-Amz-Acl: public-read\r\nUser-Agent: aws-sdk-ruby/1.25.0 jruby/1.9.2 java\r\nDate: Wed, 13 Nov 2013 14:19:59 GMT\r\nAuthorization: AWS **cut**\r\nAccept: */*\r\nHost: s3-eu-west-1.amazonaws.com\r\n\r\n"
<- "TEST"
-> "HTTP/1.1 200 OK\r\n"
-> "x-amz-id-2: **cut**\r\n"
-> "x-amz-request-id: **cut**\r\n"
-> "Date: Wed, 13 Nov 2013 14:20:03 GMT\r\n"
-> "ETag: \"**cut**\"\r\n"
-> "Content-Length: 0\r\n"
-> "Server: AmazonS3\r\n"
-> "\r\n"
reading 0 bytes...
-> ""
read 0 bytes
Conn keep-alive
[AWS S3 200 1.562 0 retries] 

I'm not sure if it's bug of JRuby or Amazon.
For now I will just stay with JRuby 1.6.7.2.

@enebo
Copy link
Member

enebo commented Feb 17, 2017

Based on following that aws link I can see updating jruby-openssl seemed to have resolved at least one reporters issue. Speculavely closing since this is >3 years since any activity. Please open a new issue if you are still experiencing problems.

@enebo enebo closed this as completed Feb 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants