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

Adds fix for content-lenght value missing for files uploaded via ActionD... #622

Merged
merged 1 commit into from
Dec 2, 2014

Conversation

hectorcorrea
Copy link
Member

...ispatch:Http::UploadedFile

@coveralls
Copy link

Coverage Status

Coverage increased (+0.0%) when pulling 0f479d6 on file_upload_fix into e9d12ca on fedora-4.

def initialize
@content = StringIO.new("hello world")
end
def bytesize
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add some whitespace between the methods.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this method ever used?

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.21%) when pulling 7c47e59 on file_upload_fix into e9d12ca on fedora-4.

@@ -254,6 +254,9 @@ def save(*)
payload = behaves_like_io?(content) ? content.read : content
headers = { 'Content-Type' => mime_type }
headers['Content-Disposition'] = "attachment; filename=\"#{@original_name}\"" if @original_name
# Setting the content-lenght is required until we figure out why Faraday
# is not doing this automatically for files uploaded via ActionDispatch.
headers['Content-Length'] = payload.size.to_s if payload.is_a?(ActionDispatch::Http::UploadedFile)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jcoyne Although I like the payload.is_a? approach better than using payload.class.name == "ActionDispatch::Http::UploadedFile" that problem with payload.is_a? is that it will force a dependency between ActiveFedora and ActionDispatch::Http::UploadedFile and the code won't run unless the class ActionDispatch::Http::UploadedFile is defined.

I am thinking of reverting back to class.name == "ActionDispatch::Http::UploadedFile". Thoughts?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jcoyne I could also do defined?(ActionDispatch::Http::UploadedFile) and payload.is_a?(ActionDispatch::Http::UploadedFile)

That seems like a good compromise.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's a good idea.

@@ -292,6 +295,10 @@ def stream(range = nil, &block)

private

def is_actiondispatch_uploadedfile?(payload)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about something shorter like def uploaded_file?(payload) or is that misleading?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mjgiarlo I like the shorter name better too. I can go either way.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.14%) when pulling 30275f9 on file_upload_fix into 5297754 on fedora-4.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.01%) when pulling 979b068 on file_upload_fix into 1d51257 on fedora-4.

jcoyne added a commit that referenced this pull request Dec 2, 2014
Adds fix for content-lenght value missing for files uploaded via ActionD...
@jcoyne jcoyne merged commit 8033161 into fedora-4 Dec 2, 2014
@jcoyne jcoyne deleted the file_upload_fix branch December 2, 2014 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants