Code Monkey home page Code Monkey logo

Comments (9)

technoweenie avatar technoweenie commented on July 20, 2024

Does it work with just File.open(temp_path, "rb")? #read will read it all into memory, which you do not want for large files. The S3Object#write method is designed to stream IO objects.

from attachment_fu.

diegolopez avatar diegolopez commented on July 20, 2024

Yes!

So the example is:
def save_to_storage
if save_attachment?
@object = @@container.create_object(full_filename)
#FIXME: ugly hack to get it running on windows
#somehow when You give file handle it won't read it
if RUBY_PLATFORM =~ /(:?mswin|mingw)/
@object.write((temp_path ? File.open(temp_path, "rb") : temp_data))
else
@object.write((temp_path ? File.open(temp_path) : temp_data))
end
end

    @old_filename = nil
    true
  end

Thanks!!
I will edit the previous post.

from attachment_fu.

technoweenie avatar technoweenie commented on July 20, 2024

Is this from the master branch? I haven't used this plugin in years. Also, you don't need the RUBY_PLATFORM check. You can pass 'rb' to it on unix systems. Other non-windows systems happily ignore the 'b'.

from attachment_fu.

diegolopez avatar diegolopez commented on July 20, 2024

Does linux works ok with File.open(temp_path, "rb") ?
So we don't need to do that ugly condition!

from attachment_fu.

technoweenie avatar technoweenie commented on July 20, 2024

Correct.

from attachment_fu.

diegolopez avatar diegolopez commented on July 20, 2024

I haven't commited my code...

from attachment_fu.

technoweenie avatar technoweenie commented on July 20, 2024

You should do that...?

from attachment_fu.

diegolopez avatar diegolopez commented on July 20, 2024

ok. thanks. I'll do it.

from attachment_fu.

technoweenie avatar technoweenie commented on July 20, 2024

Ah yes, a pull request would be great if you want credit :)

from attachment_fu.

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.