From d1e6c64d5ecafd6938df00319761033224f45f57 Mon Sep 17 00:00:00 2001 From: Oleksii Kriuchykhin Date: Sun, 28 Oct 2018 18:39:34 +0100 Subject: [PATCH] Fix API endpoints that return file URLs [SCI-2771] --- app/serializers/api/v1/repository_asset_value_serializer.rb | 2 +- app/serializers/api/v1/result_asset_serializer.rb | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/app/serializers/api/v1/repository_asset_value_serializer.rb b/app/serializers/api/v1/repository_asset_value_serializer.rb index 35c576de7..c6099a3fd 100644 --- a/app/serializers/api/v1/repository_asset_value_serializer.rb +++ b/app/serializers/api/v1/repository_asset_value_serializer.rb @@ -18,7 +18,7 @@ module Api end def url - if !object.asset&.file_present + if !object.asset&.file&.exists? nil elsif object.asset&.file&.is_stored_on_s3? object.asset.presigned_url(download: true) diff --git a/app/serializers/api/v1/result_asset_serializer.rb b/app/serializers/api/v1/result_asset_serializer.rb index f69dbbae8..0e31473a0 100644 --- a/app/serializers/api/v1/result_asset_serializer.rb +++ b/app/serializers/api/v1/result_asset_serializer.rb @@ -19,14 +19,12 @@ module Api end def url - if !object.asset&.file_present + if !object.asset&.file&.exists? nil elsif object.asset&.file&.is_stored_on_s3? object.asset.presigned_url(download: true) else - # TODO - # separate api endpoint for local files download is needed - 'url'#download_asset_path(object.asset.id) + object.asset.file.url end end end