-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Serve files without using FileStreamer-like object #1321
Conversation
@@ -42,6 +42,8 @@ Metrics/MethodLength: | |||
# Configuration parameters: CountComments. | |||
Metrics/ModuleLength: | |||
Max: 272 | |||
Exclude: |
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.
You might want to just run rubocop --auto-gen-config
for this.
Looks great. Needs a CHANGELOG entry please. |
Thanks for response! Ohhh sorry, forgot about CHANGELOG |
d3641b5
to
613f055
Compare
Updated according to your comments |
file_body = Grape::ServeFile::FileBody.new(value) | ||
@file = Grape::ServeFile::FileResponse.new(file_body) | ||
elsif !value.is_a?(NilClass) | ||
warn '[DEPRECATION] Argument as FileStreamer-like object will be deprecated. Use path to file instead' |
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.
In other places we say "is deprecated", not "will be" and usually make this a full sentence with a period in the end. Like this:
Line 50 in 4032ea8
warn '[DEPRECATION] Passing a options hash and a block to `desc` is deprecated. Move all hash options to block.' |
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 mean that support of argument as FileSteam-like object will be removed from Grape in next version after 0.15.1 or 0.16.0. After releasing 0.15.1 or 0.16.0 I would like to remove it at all. Sorry for my English :)
OK, I'll replace it with:
[DEPRECATION] Argument as FileStreamer-like object is deprecated. Use path to file instead.
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.
Thanks. If you're rubbing the bext version the old code is already deprecated but it does work with a warning. I think present tense is correct :) thanks for making the changes!
One last thing this needs is an entry in UPGRADING.md, please. |
Last thought, don't feel that strongly about it, but maybe ServeFile should just be File? |
I chose |
👍 |
|
||
Now to serve files via Grape just pass the path to the file. Functionality with FileStreamer-like objects is deprecated. | ||
|
||
Please, replace your FileStreamer-like objects with paths of served files. |
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.
Care to provide an example here? Thanks.
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.
No problem :)
Serve files without using FileStreamer-like object
Merged, thanks. |
Hello!
I've implemented serving file without using FileStremer-like object. Now user can use only path to file and Grape send file directly or will use
Rack::Sendfile
middleware if it turned on.I've saved backward compatibility with FileStreamer-like object with displaying deprecation warning.