Skip to content

Commit 5e4f2b2

Browse files
hurradieweltgehtunterVincent Petry
authored andcommitted
added user notification for file uploads > 4GB in IE11
1 parent 99c866c commit 5e4f2b2

File tree

3 files changed

+66
-1
lines changed

3 files changed

+66
-1
lines changed

apps/files/js/file-upload.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,21 @@ OC.Upload = {
336336
data.errorThrown = errorMessage;
337337
}
338338

339+
// detect browser and version to handle IE11 upload file size limit
340+
if (OC.Util.isIE11()) {
341+
var maxUploadFileSize = 4187593113;
342+
// check filesize (> 4 GB is not supported in IE11); limit is set to 3.9GB
343+
if (file.size > maxUploadFileSize) {
344+
data.textStatus = 'sizeexceedbrowserlimit';
345+
data.errorThrown = t('files',
346+
'Total file size {size1} exceeds your browser upload limit. Please use the {ownCloud} desktop client to upload files bigger than {size2}.', {
347+
'size1': humanFileSize(file.size),
348+
'ownCloud' : OC.theme.name || 'ownCloud',
349+
'size2': humanFileSize(maxUploadFileSize)
350+
});
351+
}
352+
}
353+
339354
// in case folder drag and drop is not supported file will point to a directory
340355
// http://stackoverflow.com/a/20448357
341356
if ( ! file.type && file.size%4096 === 0 && file.size <= 102400) {
@@ -583,7 +598,7 @@ OC.Upload = {
583598
+ '</span><span class="mobile">'
584599
+ t('files', '...')
585600
+ '</span></em>');
586-
$('#uploadprogressbar').tipsy({gravity:'n', fade:true, live:true});
601+
$('#uploadprogressbar').tipsy({gravity:'n', fade:true, live:true});
587602
OC.Upload._showProgressBar();
588603
});
589604
fileupload.on('fileuploadprogress', function(e, data) {

apps/files/tests/js/fileUploadSpec.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,43 @@ describe('OC.Upload tests', function() {
118118
'Not enough free space, you are uploading 5 KB but only 1000 B is left'
119119
);
120120
});
121+
it('does not add file if too big for IE11', function() {
122+
var ieStub = sinon.stub(OC.Util, 'isIE11').returns(true);
123+
var oldTheme = OC.theme.name;
124+
OC.theme.name = 'SomeThing';
125+
126+
$('#free_space').val(1000000000000);
127+
$('#upload_limit').val(1000000000000);
128+
129+
var result;
130+
testFile.size = 4187593113 + 1;
131+
result = addFile(testFile);
132+
133+
expect(result).toEqual(false);
134+
expect(failStub.calledOnce).toEqual(true);
135+
expect(failStub.getCall(0).args[1].textStatus).toEqual('sizeexceedbrowserlimit');
136+
expect(failStub.getCall(0).args[1].errorThrown).toEqual(
137+
'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.'
138+
);
139+
140+
OC.theme.name = oldTheme;
141+
ieStub.restore();
142+
});
143+
it('adds big files when not dealing with IE11', function() {
144+
var ieStub = sinon.stub(OC.Util, 'isIE11').returns(false);
145+
146+
$('#free_space').val(1000000000000);
147+
$('#upload_limit').val(1000000000000);
148+
149+
var result;
150+
testFile.size = 4187593113 + 1;
151+
result = addFile(testFile);
152+
153+
expect(result).toEqual(true);
154+
expect(failStub.notCalled).toEqual(true);
155+
156+
ieStub.restore();
157+
});
121158
});
122159
describe('Upload conflicts', function() {
123160
var oldFileList;

core/js/js.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,6 +1444,10 @@ function initCore() {
14441444
if (msie > 0 || trident > 0) {
14451445
// (IE 10 or older) || IE 11
14461446
$('html').addClass('ie');
1447+
if(trident > 0) {
1448+
var rv = userAgent.indexOf('rv:');
1449+
$('html').addClass('ie' + parseInt(userAgent.substring(rv + 3, userAgent.indexOf('.', rv)), 10));
1450+
}
14471451
} else if (edge > 0) {
14481452
// for edge
14491453
$('html').addClass('edge');
@@ -1870,6 +1874,15 @@ OC.Util = {
18701874
return $('html').hasClass('ie');
18711875
},
18721876

1877+
/**
1878+
* Returns whether this is IE11
1879+
*
1880+
* @return {bool} true if this is IE11, false otherwise
1881+
*/
1882+
isIE11: function() {
1883+
return $('html').hasClass('ie11');
1884+
},
1885+
18731886
/**
18741887
* Returns whether this is IE8
18751888
*

0 commit comments

Comments
 (0)