diff options
Diffstat (limited to 'app/controllers/concerns/uploads_actions.rb')
-rw-r--r-- | app/controllers/concerns/uploads_actions.rb | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/app/controllers/concerns/uploads_actions.rb b/app/controllers/concerns/uploads_actions.rb index 4ec0e94df9a..5657bdf916d 100644 --- a/app/controllers/concerns/uploads_actions.rb +++ b/app/controllers/concerns/uploads_actions.rb @@ -4,7 +4,7 @@ module UploadsActions include Gitlab::Utils::StrongMemoize include SendFileUpload - UPLOAD_MOUNTS = %w(avatar attachment file logo header_logo favicon).freeze + UPLOAD_MOUNTS = %w[avatar attachment file logo header_logo favicon].freeze def create uploader = UploadService.new(model, params[:file], uploader_class).execute @@ -12,11 +12,11 @@ module UploadsActions respond_to do |format| if uploader format.json do - render json: { link: uploader.to_h } + render json: {link: uploader.to_h} end else format.json do - render json: 'Invalid file.', status: :unprocessable_entity + render json: "Invalid file.", status: :unprocessable_entity end end end @@ -31,13 +31,13 @@ module UploadsActions if cache_publicly? # We need to reset caching from the applications controller to get rid of the no-store value - headers['Cache-Control'] = '' + headers["Cache-Control"] = "" expires_in 5.minutes, public: true, must_revalidate: false else expires_in 0.seconds, must_revalidate: true, private: true end - disposition = uploader.image_or_video? ? 'inline' : 'attachment' + disposition = uploader.image_or_video? ? "inline" : "attachment" uploaders = [uploader, *uploader.versions.values] uploader = uploaders.find { |version| version.filename == params[:filename] } @@ -53,7 +53,8 @@ module UploadsActions authorized = uploader_class.workhorse_authorize( has_length: false, - maximum_size: Gitlab::CurrentSettings.max_attachment_size.megabytes.to_i) + maximum_size: Gitlab::CurrentSettings.max_attachment_size.megabytes.to_i + ) render json: authorized rescue SocketError @@ -113,7 +114,7 @@ module UploadsActions end def image_or_video? - uploader && uploader.exists? && uploader.image_or_video? + uploader&.exists? && uploader&.image_or_video? end def find_model |