#1150 Uploading big files

This commit is contained in:
karel.picman@lbcfree.net 2020-07-20 08:08:51 +02:00
parent a334dd7a9e
commit 2b56634c7b
8 changed files with 40 additions and 21 deletions

View File

@ -62,7 +62,7 @@ class DmsfUploadController < ApplicationController
return
end
@attachment = Attachment.new(file: request.raw_post)
@attachment = Attachment.new(file: request.body)
@attachment.author = User.current
@attachment.filename = params[:filename].presence || Redmine::Utils.random_hex(16)
@attachment.content_type = params[:content_type].presence

View File

@ -22,7 +22,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
%>
<div class="box tabular" style="padding-top: 10px">
<div class="box tabular dmfs-box-tabular">
<%= hidden_field_tag "commited_files[#{i}][disk_filename]", upload.disk_filename %>
<%= hidden_field_tag "commited_files[#{i}][tempfile_path]", upload.tempfile_path %>
<%= hidden_field_tag "commited_files[#{i}][size]", upload.size %>

View File

@ -22,7 +22,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
%>
<div class="box tabular" style="padding-top: 10px">
<div class="box tabular dmfs-box-tabular">
<%= hidden_field_tag "commited_files[#{i}][disk_filename]", upload.disk_filename %>
<%= hidden_field_tag "commited_files[#{i}][tempfile_path]", upload.tempfile_path %>
<%= hidden_field_tag "commited_files[#{i}][size]", upload.size %>

View File

@ -1 +1,23 @@
<%
# encoding: utf-8
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-20 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
%>
$('#dmsf_attachments_<%= j params[:attachment_id] %>').remove();

View File

@ -23,7 +23,7 @@
<%= render partial: '/dmsf/path',
locals: { folder: @folder, filename: nil, title: l(:label_attachment_new) } %>
<%= form_tag({ controller: 'dmsf_upload', action: 'upload_files', id: @project, folder_id: @folder },
id: 'uploadform', method: :post, multipart: true) do %>
{ id: 'uploadform', multipart: true }) do %>
<div class="box tabular">
<span class="dmsf-uploader">
<%= render partial: 'dmsf_upload/form',

View File

@ -113,7 +113,7 @@ function dmsfAjaxUpload(file, attachmentId, fileSpan, inputEl) {
function onProgress(e) {
if(e.lengthComputable) {
this.progressbar( 'value', e.loaded * 100 / e.total );
this.progressbar('value', e.loaded * 100 / e.total);
}
}
@ -132,11 +132,11 @@ function dmsfAjaxUpload(file, attachmentId, fileSpan, inputEl) {
.fail(function(result) {
progressSpan.text(result.statusText);
}).always(function() {
dmsfAjaxUpload.uploading--;
fileSpan.removeClass('ajax-loading');
let form = fileSpan.parents('form');
if ((form.queue('upload').length == 0) && (dmsfAjaxUpload.uploading == 0)) {
$('input:submit', form).removeAttr('disabled');
dmsfAjaxUpload.uploading--;
fileSpan.removeClass('ajax-loading');
let form = fileSpan.parents('form');
if ((form.queue('upload').length == 0) && (dmsfAjaxUpload.uploading == 0)) {
$('input:submit', form).removeAttr('disabled');
}
form.dequeue('upload');
});
@ -163,13 +163,6 @@ function dmsfRemoveFileLbl() {
return false;
}
/*function dmsfRemoveFile() {
$(this).parent('span').parent('span').remove();
return false;
}*/
function dmsfUploadBlob(blob, uploadUrl, attachmentId, options) {
let actualOptions = $.extend({

View File

@ -319,6 +319,10 @@ div[id*="revision_access_"] {
padding-left: 18px;
}
.dmfs-box-tabular {
padding-top: 10px
}
/* New link form */
#dmsf_link_target_file_id, #dmsf_link_target_folder_id, #dmsf_link_target_project_id, #dmsf_link_name{
min-width: 40%;

View File

@ -564,9 +564,9 @@ module RedmineDmsf
# Phusion passenger does not have a method "length" in its model
# however, includes a size method - so we instead use reflection
# to determine best approach to problem
if request.body.respond_to? 'length'
if request.body.respond_to?(:length)
new_revision.size = request.body.length
elsif request.body.respond_to? 'size'
elsif request.body.respond_to?(:size)
new_revision.size = request.body.size
else
new_revision.size = request.content_length # Bad Guess
@ -577,10 +577,10 @@ module RedmineDmsf
new_revision.disk_filename = new_revision.new_storage_filename unless reuse_revision
if new_revision.save
new_revision.copy_file_content(request.body)
new_revision.copy_file_content request.body
new_revision.save
# Notifications
DmsfMailer.deliver_files_updated(project, [f])
DmsfMailer.deliver_files_updated project, [f]
else
raise InternalServerError
end