Skip to content

Commit

Permalink
Remove upload_limit in files app as it is not needed with PUT upload
Browse files Browse the repository at this point in the history
The web UI now uses for PUT uploads which aren't restricted by PHP's
upload_max_filesize and post_max_size
  • Loading branch information
Vincent Petry committed Sep 8, 2016
1 parent 0751c2e commit e35d049
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 37 deletions.
15 changes: 1 addition & 14 deletions apps/files/js/file-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -768,8 +768,7 @@ OC.Uploader.prototype = _.extend({
data.originalFiles.selection = {
uploads: [],
filesToUpload: data.originalFiles.length,
totalBytes: 0,
biggestFileBytes: 0
totalBytes: 0
};
}
// TODO: move originalFiles to a separate container, maybe inside OC.Upload
Expand Down Expand Up @@ -828,18 +827,6 @@ OC.Uploader.prototype = _.extend({
} else {
// add size
selection.totalBytes += file.size;
// update size of biggest file
selection.biggestFileBytes = Math.max(selection.biggestFileBytes, file.size);
}

// check PHP upload limit against biggest file
if (selection.biggestFileBytes > $('#upload_limit').val()) {
data.textStatus = 'sizeexceedlimit';
data.errorThrown = t('files',
'Total file size {size1} exceeds upload limit {size2}', {
'size1': humanFileSize(selection.biggestFileBytes),
'size2': humanFileSize($('#upload_limit').val())
});
}

// check free space
Expand Down
2 changes: 0 additions & 2 deletions apps/files/js/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
return;
}
if (response.data !== undefined && response.data.uploadMaxFilesize !== undefined) {
$('#max_upload').val(response.data.uploadMaxFilesize);
$('#free_space').val(response.data.freeSpace);
$('#upload.button').attr('data-original-title', response.data.maxHumanFilesize);
$('#usedSpacePercent').val(response.data.usedSpacePercent);
Expand All @@ -71,7 +70,6 @@
return;
}
if (response[0].uploadMaxFilesize !== undefined) {
$('#max_upload').val(response[0].uploadMaxFilesize);
$('#upload.button').attr('data-original-title', response[0].maxHumanFilesize);
$('#usedSpacePercent').val(response[0].usedSpacePercent);
Files.displayStorageWarnings();
Expand Down
2 changes: 0 additions & 2 deletions apps/files/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@
$config = \OC::$server->getConfig();
// TODO: move this to the generated config.js
$publicUploadEnabled = $config->getAppValue('core', 'shareapi_allow_public_upload', 'yes');
$uploadLimit=OCP\Util::uploadLimit();

// renders the controls and table headers template
$tmpl = new OCP\Template('files', 'list', '');
$tmpl->assign('uploadLimit', $uploadLimit); // PHP upload limit
$tmpl->assign('publicUploadEnabled', $publicUploadEnabled);
$tmpl->printPage();

2 changes: 0 additions & 2 deletions apps/files/templates/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
through ajax instead (updateStorageStatistics).
*/ ?>
<input type="hidden" name="permissions" value="" id="permissions">
<input type="hidden" id="max_upload" name="MAX_FILE_SIZE" value="<?php isset($_['uploadMaxFilesize']) ? p($_['uploadMaxFilesize']) : '' ?>">
<input type="hidden" id="upload_limit" value="<?php isset($_['uploadLimit']) ? p($_['uploadLimit']) : '' ?>">
<input type="hidden" id="free_space" value="<?php isset($_['freeSpace']) ? p($_['freeSpace']) : '' ?>">
<?php if(isset($_['dirToken'])):?>
<input type="hidden" id="publicUploadRequestToken" name="requesttoken" value="<?php p($_['requesttoken']) ?>" />
Expand Down
14 changes: 0 additions & 14 deletions apps/files/tests/js/fileUploadSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ describe('OC.Upload tests', function() {
// need a dummy button because file-upload checks on it
$('#testArea').append(
'<input type="file" id="file_upload_start" name="files[]" multiple="multiple">' +
'<input type="hidden" id="upload_limit" name="upload_limit" value="10000000">' + // 10 MB
'<input type="hidden" id="free_space" name="free_space" value="50000000">' + // 50 MB
// TODO: handlebars!
'<div id="new">' +
Expand Down Expand Up @@ -97,19 +96,6 @@ describe('OC.Upload tests', function() {
expect(result[0].submit.calledOnce).toEqual(true);
expect(failStub.notCalled).toEqual(true);
});
it('does not add file if it exceeds upload limit', function() {
var result;
$('#upload_limit').val(1000);

result = addFiles(uploader, [testFile]);

expect(result[0]).toEqual(null);
expect(failStub.calledOnce).toEqual(true);
expect(failStub.getCall(0).args[1].textStatus).toEqual('sizeexceedlimit');
expect(failStub.getCall(0).args[1].errorThrown).toEqual(
'Total file size 5 KB exceeds upload limit 1000 B'
);
});
it('does not add file if it exceeds free space', function() {
var result;
$('#free_space').val(1000);
Expand Down
4 changes: 1 addition & 3 deletions apps/files_sharing/lib/Controllers/ShareController.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,7 @@ public function showShare($token, $path = '') {
$freeSpace = (INF > 0) ? INF: PHP_INT_MAX; // work around https://bugs.php.net/bug.php?id=69188
}

$uploadLimit = Util::uploadLimit();
$maxUploadFilesize = min($freeSpace, $uploadLimit);
$maxUploadFilesize = $freeSpace;

$folder = new Template('files', 'list', '');
$folder->assign('dir', $rootFolder->getRelativePath($path->getPath()));
Expand All @@ -339,7 +338,6 @@ public function showShare($token, $path = '') {
$folder->assign('uploadMaxFilesize', $maxUploadFilesize);
$folder->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize));
$folder->assign('freeSpace', $freeSpace);
$folder->assign('uploadLimit', $uploadLimit); // PHP upload limit
$folder->assign('usedSpacePercent', 0);
$folder->assign('trash', false);
$shareTmpl['folder'] = $folder->fetchPage();
Expand Down

0 comments on commit e35d049

Please sign in to comment.