Open diegolopez opened 14 years ago
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.
Yes!
So the example is: def save_to_storage if save_attachment? @object = @@container.create_object(full_filename)
#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.
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'.
Does linux works ok with File.open(temp_path, "rb") ? So we don't need to do that ugly condition!
Correct.
I haven't commited my code...
You should do that...?
ok. thanks. I'll do it.
Ah yes, a pull request would be great if you want credit :)
You have to change the save_to_storage from s3 and rackspace backends so instead of: (temp_path ? File.open(temp_path) : temp_data) you do: (temp_path ? File.open(temp_path, "rb") : temp_data)
Example for rackspace: