Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

user notification for file uploads > 4GB in IE11 #27004

Merged
merged 1 commit into from
Jan 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion apps/files/js/file-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,21 @@ OC.Upload = {
data.errorThrown = errorMessage;
}

// detect browser and version to handle IE11 upload file size limit
if (OC.Util.isIE11()) {
var maxUploadFileSize = 4187593113;
// check filesize (> 4 GB is not supported in IE11); limit is set to 3.9GB
if (file.size > maxUploadFileSize) {
data.textStatus = 'sizeexceedbrowserlimit';
data.errorThrown = t('files',
'Total file size {size1} exceeds your browser upload limit. Please use the {ownCloud} desktop client to upload files bigger than {size2}.', {
'size1': humanFileSize(file.size),
'ownCloud' : OC.theme.name || 'ownCloud',
'size2': humanFileSize(maxUploadFileSize)
});
}
}

// in case folder drag and drop is not supported file will point to a directory
// http://stackoverflow.com/a/20448357
if ( ! file.type && file.size%4096 === 0 && file.size <= 102400) {
Expand Down Expand Up @@ -583,7 +598,7 @@ OC.Upload = {
+ '</span><span class="mobile">'
+ t('files', '...')
+ '</span></em>');
$('#uploadprogressbar').tipsy({gravity:'n', fade:true, live:true});
$('#uploadprogressbar').tipsy({gravity:'n', fade:true, live:true});
OC.Upload._showProgressBar();
});
fileupload.on('fileuploadprogress', function(e, data) {
Expand Down
37 changes: 37 additions & 0 deletions apps/files/tests/js/fileUploadSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,43 @@ describe('OC.Upload tests', function() {
'Not enough free space, you are uploading 5 KB but only 1000 B is left'
);
});
it('does not add file if too big for IE11', function() {
var ieStub = sinon.stub(OC.Util, 'isIE11').returns(true);
var oldTheme = OC.theme.name;
OC.theme.name = 'SomeThing';

$('#free_space').val(1000000000000);
$('#upload_limit').val(1000000000000);

var result;
testFile.size = 4187593113 + 1;
result = addFile(testFile);

expect(result).toEqual(false);
expect(failStub.calledOnce).toEqual(true);
expect(failStub.getCall(0).args[1].textStatus).toEqual('sizeexceedbrowserlimit');
expect(failStub.getCall(0).args[1].errorThrown).toEqual(
'Total file size 3.9 GB exceeds your browser upload limit. Please use the SomeThing desktop client to upload files bigger than 3.9 GB.'
);

OC.theme.name = oldTheme;
ieStub.restore();
});
it('adds big files when not dealing with IE11', function() {
var ieStub = sinon.stub(OC.Util, 'isIE11').returns(false);

$('#free_space').val(1000000000000);
$('#upload_limit').val(1000000000000);

var result;
testFile.size = 4187593113 + 1;
result = addFile(testFile);

expect(result).toEqual(true);
expect(failStub.notCalled).toEqual(true);

ieStub.restore();
});
});
describe('Upload conflicts', function() {
var oldFileList;
Expand Down
13 changes: 13 additions & 0 deletions core/js/js.js
Original file line number Diff line number Diff line change
Expand Up @@ -1444,6 +1444,10 @@ function initCore() {
if (msie > 0 || trident > 0) {
// (IE 10 or older) || IE 11
$('html').addClass('ie');
if(trident > 0) {
var rv = userAgent.indexOf('rv:');
$('html').addClass('ie' + parseInt(userAgent.substring(rv + 3, userAgent.indexOf('.', rv)), 10));
}
} else if (edge > 0) {
// for edge
$('html').addClass('edge');
Expand Down Expand Up @@ -1870,6 +1874,15 @@ OC.Util = {
return $('html').hasClass('ie');
},

/**
* Returns whether this is IE11
*
* @return {bool} true if this is IE11, false otherwise
*/
isIE11: function() {
return $('html').hasClass('ie11');
},

/**
* Returns whether this is IE8
*
Expand Down