Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

refactor to use grape helpers

Christophe Bliard8015989a62d7
diff --git a/modules/storages/lib/api/v3/file_links/file_links_open_api.rb b/modules/storages/lib/api/v3/file_links/file_links_open_api.rb
index a04eaca115f..158b51b07fa 100644
--- a/modules/storages/lib/api/v3/file_links/file_links_open_api.rb
+++ b/modules/storages/lib/api/v3/file_links/file_links_open_api.rb
@@ -32,14 +32,13 @@ module API
class FileLinksOpenAPI < ::API::OpenProjectAPI
resources :open do
get do
- call = ::Storages::StorageUrlService.new(@file_link).call('open')
- raise StandardError.new 'Cannot create opening url for linked file.' if call.failure?
+ service_call = ::Storages::StorageUrlService.new(@file_link).call('open')
- url = call.result
- status 303
- header 'Location', url
- content_type 'text/plain'
- body "The requested resource can be viewed at #{url}"
+ raise StandardError, 'Cannot create opening url for linked file.' if service_call.failure?
+
+ url = service_call.result
+ redirect url, body: "The requested resource can be viewed at #{url}"
+ status 303 # The follow-up request to the resource must be GET
end
end
end