#1150 Uploading big files
This commit is contained in:
parent
a334dd7a9e
commit
2b56634c7b
@ -62,7 +62,7 @@ class DmsfUploadController < ApplicationController
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@attachment = Attachment.new(file: request.raw_post)
|
@attachment = Attachment.new(file: request.body)
|
||||||
@attachment.author = User.current
|
@attachment.author = User.current
|
||||||
@attachment.filename = params[:filename].presence || Redmine::Utils.random_hex(16)
|
@attachment.filename = params[:filename].presence || Redmine::Utils.random_hex(16)
|
||||||
@attachment.content_type = params[:content_type].presence
|
@attachment.content_type = params[:content_type].presence
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# 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}][disk_filename]", upload.disk_filename %>
|
||||||
<%= hidden_field_tag "commited_files[#{i}][tempfile_path]", upload.tempfile_path %>
|
<%= hidden_field_tag "commited_files[#{i}][tempfile_path]", upload.tempfile_path %>
|
||||||
<%= hidden_field_tag "commited_files[#{i}][size]", upload.size %>
|
<%= hidden_field_tag "commited_files[#{i}][size]", upload.size %>
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# 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}][disk_filename]", upload.disk_filename %>
|
||||||
<%= hidden_field_tag "commited_files[#{i}][tempfile_path]", upload.tempfile_path %>
|
<%= hidden_field_tag "commited_files[#{i}][tempfile_path]", upload.tempfile_path %>
|
||||||
<%= hidden_field_tag "commited_files[#{i}][size]", upload.size %>
|
<%= hidden_field_tag "commited_files[#{i}][size]", upload.size %>
|
||||||
|
|||||||
@ -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();
|
$('#dmsf_attachments_<%= j params[:attachment_id] %>').remove();
|
||||||
|
|||||||
@ -23,7 +23,7 @@
|
|||||||
<%= render partial: '/dmsf/path',
|
<%= render partial: '/dmsf/path',
|
||||||
locals: { folder: @folder, filename: nil, title: l(:label_attachment_new) } %>
|
locals: { folder: @folder, filename: nil, title: l(:label_attachment_new) } %>
|
||||||
<%= form_tag({ controller: 'dmsf_upload', action: 'upload_files', id: @project, folder_id: @folder },
|
<%= 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">
|
<div class="box tabular">
|
||||||
<span class="dmsf-uploader">
|
<span class="dmsf-uploader">
|
||||||
<%= render partial: 'dmsf_upload/form',
|
<%= render partial: 'dmsf_upload/form',
|
||||||
|
|||||||
@ -113,7 +113,7 @@ function dmsfAjaxUpload(file, attachmentId, fileSpan, inputEl) {
|
|||||||
|
|
||||||
function onProgress(e) {
|
function onProgress(e) {
|
||||||
if(e.lengthComputable) {
|
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) {
|
.fail(function(result) {
|
||||||
progressSpan.text(result.statusText);
|
progressSpan.text(result.statusText);
|
||||||
}).always(function() {
|
}).always(function() {
|
||||||
dmsfAjaxUpload.uploading--;
|
dmsfAjaxUpload.uploading--;
|
||||||
fileSpan.removeClass('ajax-loading');
|
fileSpan.removeClass('ajax-loading');
|
||||||
let form = fileSpan.parents('form');
|
let form = fileSpan.parents('form');
|
||||||
if ((form.queue('upload').length == 0) && (dmsfAjaxUpload.uploading == 0)) {
|
if ((form.queue('upload').length == 0) && (dmsfAjaxUpload.uploading == 0)) {
|
||||||
$('input:submit', form).removeAttr('disabled');
|
$('input:submit', form).removeAttr('disabled');
|
||||||
}
|
}
|
||||||
form.dequeue('upload');
|
form.dequeue('upload');
|
||||||
});
|
});
|
||||||
@ -163,13 +163,6 @@ function dmsfRemoveFileLbl() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*function dmsfRemoveFile() {
|
|
||||||
|
|
||||||
$(this).parent('span').parent('span').remove();
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
function dmsfUploadBlob(blob, uploadUrl, attachmentId, options) {
|
function dmsfUploadBlob(blob, uploadUrl, attachmentId, options) {
|
||||||
|
|
||||||
let actualOptions = $.extend({
|
let actualOptions = $.extend({
|
||||||
|
|||||||
@ -319,6 +319,10 @@ div[id*="revision_access_"] {
|
|||||||
padding-left: 18px;
|
padding-left: 18px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.dmfs-box-tabular {
|
||||||
|
padding-top: 10px
|
||||||
|
}
|
||||||
|
|
||||||
/* New link form */
|
/* New link form */
|
||||||
#dmsf_link_target_file_id, #dmsf_link_target_folder_id, #dmsf_link_target_project_id, #dmsf_link_name{
|
#dmsf_link_target_file_id, #dmsf_link_target_folder_id, #dmsf_link_target_project_id, #dmsf_link_name{
|
||||||
min-width: 40%;
|
min-width: 40%;
|
||||||
|
|||||||
@ -564,9 +564,9 @@ module RedmineDmsf
|
|||||||
# Phusion passenger does not have a method "length" in its model
|
# Phusion passenger does not have a method "length" in its model
|
||||||
# however, includes a size method - so we instead use reflection
|
# however, includes a size method - so we instead use reflection
|
||||||
# to determine best approach to problem
|
# to determine best approach to problem
|
||||||
if request.body.respond_to? 'length'
|
if request.body.respond_to?(:length)
|
||||||
new_revision.size = request.body.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
|
new_revision.size = request.body.size
|
||||||
else
|
else
|
||||||
new_revision.size = request.content_length # Bad Guess
|
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
|
new_revision.disk_filename = new_revision.new_storage_filename unless reuse_revision
|
||||||
|
|
||||||
if new_revision.save
|
if new_revision.save
|
||||||
new_revision.copy_file_content(request.body)
|
new_revision.copy_file_content request.body
|
||||||
new_revision.save
|
new_revision.save
|
||||||
# Notifications
|
# Notifications
|
||||||
DmsfMailer.deliver_files_updated(project, [f])
|
DmsfMailer.deliver_files_updated project, [f]
|
||||||
else
|
else
|
||||||
raise InternalServerError
|
raise InternalServerError
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user