From: Brett Smith Date: Thu, 15 May 2014 19:54:32 +0000 (-0400) Subject: 2764: Introduce show_file_links route. X-Git-Tag: 1.1.0~2612^2~1^2^2~4 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/1924b28c8f715bc08752fb219d1fd8145ccfe84f 2764: Introduce show_file_links route. Right now this just takes advantage of the provided reader token, but we're going to extend it to provide a wget-friendly view. --- diff --git a/apps/workbench/app/controllers/collections_controller.rb b/apps/workbench/app/controllers/collections_controller.rb index 43ff754da8..7a8888e1d2 100644 --- a/apps/workbench/app/controllers/collections_controller.rb +++ b/apps/workbench/app/controllers/collections_controller.rb @@ -1,7 +1,8 @@ class CollectionsController < ApplicationController - skip_around_filter :thread_with_mandatory_api_token, only: [:show_file] - skip_before_filter :find_object_by_uuid, only: [:provenance, :show_file] - skip_before_filter :check_user_agreements, only: [:show_file] + skip_around_filter(:thread_with_mandatory_api_token, + only: [:show_file, :show_file_links]) + skip_before_filter(:find_object_by_uuid, + only: [:provenance, :show_file, :show_file_links]) RELATION_LIMIT = 5 @@ -89,6 +90,13 @@ class CollectionsController < ApplicationController @request_url = request.url end + def show_file_links + Thread.current[:reader_tokens] = [params[:reader_token]] + find_object_by_uuid + show + render 'show' + end + def show_file # We pipe from arv-get to send the file to the user. Before we start it, # we ask the API server if the file actually exists. This serves two diff --git a/apps/workbench/config/routes.rb b/apps/workbench/config/routes.rb index 30ac241333..c12cc989d7 100644 --- a/apps/workbench/config/routes.rb +++ b/apps/workbench/config/routes.rb @@ -44,9 +44,10 @@ ArvadosWorkbench::Application.routes.draw do resources :collections do post 'set_persistent', on: :member end - get '/collections/:uuid/*file' => 'collections#show_file', :format => false get('/collections/download/:uuid/:reader_token/*file' => 'collections#show_file', format: false) + get '/collections/download/:uuid/:reader_token' => 'collections#show_file_links' + get '/collections/:uuid/*file' => 'collections#show_file', :format => false resources :folders do match 'remove/:item_uuid', on: :member, via: :delete, action: :remove_item end diff --git a/apps/workbench/test/functional/collections_controller_test.rb b/apps/workbench/test/functional/collections_controller_test.rb index b31e718e4d..19d08d73b3 100644 --- a/apps/workbench/test/functional/collections_controller_test.rb +++ b/apps/workbench/test/functional/collections_controller_test.rb @@ -89,11 +89,10 @@ class CollectionsControllerTest < ActionController::TestCase end test "viewing collection files with a reader token" do - skip # Need a new route+view for this. params = collection_params(:foo_file) params[:reader_token] = api_fixture('api_client_authorizations')['active']['api_token'] - get(:show, params) + get(:show_file_links, params) assert_response :success assert_equal([['.', 'foo', 3]], assigns(:object).files) assert_no_session