From: Tom Clegg Date: Thu, 2 Jan 2014 17:41:06 +0000 (-0800) Subject: Link to show/download files from collections. refs #1748 X-Git-Tag: 1.1.0~2722^2~115^2~1 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/d0f8dba42b3a4c1ca3ae66bb4ad79ec78a1d26d5 Link to show/download files from collections. refs #1748 --- diff --git a/apps/workbench/app/controllers/collections_controller.rb b/apps/workbench/app/controllers/collections_controller.rb index 3cea60b9d9..bf311dd5a9 100644 --- a/apps/workbench/app/controllers/collections_controller.rb +++ b/apps/workbench/app/controllers/collections_controller.rb @@ -48,6 +48,8 @@ class CollectionsController < ApplicationController end self.response.headers['Content-Type'] = Rack::Mime::MIME_TYPES[ext] || 'application/octet-stream' + self.response.headers['Content-Length'] = params[:size] if params[:size] + self.response.headers['Content-Disposition'] = params[:disposition] if params[:disposition] self.response_body = FileStreamer.new opts end diff --git a/apps/workbench/app/views/collections/show.html.erb b/apps/workbench/app/views/collections/show.html.erb index 3dc97628c2..cc8eec352f 100644 --- a/apps/workbench/app/views/collections/show.html.erb +++ b/apps/workbench/app/views/collections/show.html.erb @@ -27,16 +27,29 @@
- +
- + + + + - <% if @object then @object.files.each do |file| %> + <% if @object then @object.files.sort_by{|f|f[1]}.each do |file| %> + <% file_path = "#{file[0]}/#{file[1]}" %> <% end; end %>
size (bytes)filename
size +
+ path +
<%= raw(human_readable_bytes_html(file[2])) %> - <%= file[0] %>/<%= file[1] %> +
+ <%= link_to raw(''), {controller: 'collections', action: 'show_file', uuid: @object.uuid, file: file_path, size: file[2], disposition: 'attachment'}, {class: 'label label-info', title: 'Download'} %> + <% if file_path.match /\.(txt|pdf|png|jpe?g|gif|tiff?)$/i %> + <%= link_to raw(''), {controller: 'collections', action: 'show_file', uuid: @object.uuid, file: file_path, size: file[2], disposition: 'inline'}, {class: 'label label-info', title: 'View in browser'} %> + <% end %> +
+ <%= file_path %>