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
Add support for fog streaming uploads #467
Add support for fog streaming uploads #467
Conversation
Fog supports streaming uploads if passed a File object. Added SanitizedFile#to_file method that returns a File object. This works for file system based SanitizedFile (File, Tempfile, Hash, etc) StringIO must still be read into memory before being passed to fog.
@geemus would you mind reviewing this? |
# [File] a File object representing the SanitizedFile | ||
# | ||
def to_file | ||
File.open(@file) if exists? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like this should perhaps use is_path?
for consistency with read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that exists?
will work better here. is_path?
will return false for a SanitizedFile
created from either a File
or Tempfile
object, which means that the entire contents will be read into memory before being passed to fog.
This code will needlessly create a new File
object if @file
is already a File
. Maybe I should change the first line to this:
return @file if @file.is_a?(File)
Other than that one thing it looks good (basically the main difference is passing a file handle, ie |
Shouldn't rely on #exists? here, since #to_file implementation might change.
Seems reasonable I think. |
Thanks for looking @geemus. @chrisdurtschi I'm getting lots of test failures. Did you run the full test suite with your changes?
Please re-open this pull request or open a new pull request if/when you have time to fix things. |
Sorry, I only tested in 1.9.2. I'm getting these same failures in 1.8.7. I'll look into it and send a new pull request. |
Thanks! |
Fog supports streaming uploads if passed a File object.
Added SanitizedFile#to_file method that returns a File object.
This works for file system based SanitizedFile (File, Tempfile, Hash, etc)
StringIO must still be read into memory before being passed to fog.