Code Monkey home page Code Monkey logo

Comments (7)

qoobaa avatar qoobaa commented on August 23, 2024

I'm sorry for the delay. I'm quite busy recently, so I'm afraid you need to debug the code on your own. You can also consider switching to a different S3 library.

from s3.

mitfik avatar mitfik commented on August 23, 2024

Hi, I had the same problem I will try to debug it but for me solution was:

File.open("file.png", :encoding => "BINARY")

Binary is the key.
If I will find out solution You could find it in my fork.

edit

Is really weird because right now it works even without binary attribute. Something strange going on.

from s3.

qoobaa avatar qoobaa commented on August 23, 2024

Thanks for reporting, please create a pull request when you fix the problem.

from s3.

abunsenonesale avatar abunsenonesale commented on August 23, 2024

For anyone trying to figure this out, use File.read instead of File.open or open

from s3.

mitfik avatar mitfik commented on August 23, 2024

@abunsenonesale Do you know how to reproduce this error?
Could you also provide explanation for that why read is better then open in this case?

I could not reproduce that error so I do not know if it was related with some specific ruby version or some other black magic.
If you could provide some details it will be cool to understand what happened and to fix that.

from s3.

IanVaughan avatar IanVaughan commented on August 23, 2024

I have this now, although it was working when I initially implemented it, it now doesn't!

require "s3"

service = S3::Service.new(
  :access_key_id     => ENV['ACCESS_KEY_ID'],
  :secret_access_key => ENV['SECRET_ACCESS_KEY']
)

bucket_name = ENV['BUCKET_NAME']
file = ENV['FILENAME']

bucket = service.buckets.find(bucket_name)

object = bucket.objects.build(file)
object.content = open(file)
object.save

Result

S3::Error::RequestTimeout: Your socket connection to the server was not read from or written to within the timeout period. Idle connections will be closed.
from /Users/ian/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/s3-0.3.23/lib/s3/connection.rb:216:in `handle_response'

Using : ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin14]

[13] pry(main)> object.content = File.open("/Users/ian/Desktop/test.png")
=> #<File:/Users/ian/Desktop/test.png>

from s3.

mauriciofloresl avatar mauriciofloresl commented on August 23, 2024

Reading over here aws/aws-sdk-js#281 it seems it's an issue with the content-length.

from s3.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.