Merge pull request #2620 from okriuchykhin/ok_SCI_4673

Fix file download from MS Office online [SCI-4673]
This commit is contained in:
Alex Kriuchykhin 2020-05-28 13:09:14 +02:00 committed by GitHub
commit 5ce1311591
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 3 deletions

View file

@ -102,6 +102,10 @@ class AssetsController < ApplicationController
render plain: @asset.file.blob.service_url
end
def download
redirect_to rails_blob_path(@asset.file, disposition: 'attachment')
end
def edit
action = @asset.file_size.zero? && !@asset.locked? ? 'editnew' : 'edit'
@action_url = append_wd_params(@asset.get_action_url(current_user, action, false))

View file

@ -48,6 +48,8 @@ class WopiController < ActionController::Base
put_file
end
private
def check_file_info
asset_owner_id = @asset.id.to_s
asset_owner_id = @asset.created_by_id.to_s if @asset.created_by_id
@ -69,7 +71,7 @@ class WopiController < ActionController::Base
UserCanWrite: @can_write,
UserCanNotWriteRelative: true,
CloseUrl: @close_url,
DownloadUrl: url_for(controller: 'assets', action: 'file_url', id: @asset.id, host: ENV['WOPI_USER_HOST']),
DownloadUrl: url_for(controller: 'assets', action: 'download', id: @asset.id, host: ENV['WOPI_USER_HOST']),
HostEditUrl: url_for(controller: 'assets', action: 'edit', id: @asset.id, host: ENV['WOPI_USER_HOST']),
HostViewUrl: url_for(controller: 'assets', action: 'view', id: @asset.id, host: ENV['WOPI_USER_HOST']),
BreadcrumbBrandName: @breadcrumb_brand_name,
@ -260,8 +262,6 @@ class WopiController < ActionController::Base
end
end
private
def authenticate_user_from_token!
wopi_token = params[:access_token]
if wopi_token.nil?

View file

@ -685,6 +685,7 @@ Rails.application.routes.draw do
get 'files/:id/preview', to: 'assets#preview', as: 'preview_asset'
get 'files/:id/view', to: 'assets#view', as: 'view_asset'
get 'files/:id/file_url', to: 'assets#file_url', as: 'asset_file_url'
get 'files/:id/download', to: 'assets#download', as: 'asset_download'
get 'files/:id/edit', to: 'assets#edit', as: 'edit_asset'
post 'files/:id/update_image', to: 'assets#update_image',
as: 'update_asset_image'