summaryrefslogtreecommitdiffstats
path: root/apps/files/ajax
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2013-01-18 14:06:00 -0800
committerThomas Müller <thomas.mueller@tmit.eu>2013-01-18 14:06:00 -0800
commit31cc9aa80d4284e13dc95d2ef1428bed78c22d65 (patch)
tree3b42e3a95bc0a92cd75bba16438e9dcf55f49e89 /apps/files/ajax
parentedf3572835ac5a6584fdde7ba7bb1faa64251e2d (diff)
parent5ff29b4348a1dcb9ed32273133b1c787aaf5c72c (diff)
downloadnextcloud-server-31cc9aa80d4284e13dc95d2ef1428bed78c22d65.tar.gz
nextcloud-server-31cc9aa80d4284e13dc95d2ef1428bed78c22d65.zip
Merge pull request #986 from owncloud/fixing-784-master
the maximum upload size is now part of the response of the upload and de...
Diffstat (limited to 'apps/files/ajax')
-rw-r--r--apps/files/ajax/delete.php16
-rw-r--r--apps/files/ajax/getstoragestats.php16
-rw-r--r--apps/files/ajax/upload.php35
3 files changed, 60 insertions, 7 deletions
diff --git a/apps/files/ajax/delete.php b/apps/files/ajax/delete.php
index 6532b76df21..293543c547f 100644
--- a/apps/files/ajax/delete.php
+++ b/apps/files/ajax/delete.php
@@ -21,8 +21,20 @@ foreach($files as $file) {
}
}
+// updated max file size after upload
+$l=new OC_L10N('files');
+$maxUploadFilesize=OCP\Util::maxUploadFilesize($dir);
+$maxHumanFilesize=OCP\Util::humanFileSize($maxUploadFilesize);
+$maxHumanFilesize=$l->t('Upload') . ' max. '.$maxHumanFilesize;
+
if($success) {
- OCP\JSON::success(array("data" => array( "dir" => $dir, "files" => $files )));
+ OCP\JSON::success(array("data" => array( "dir" => $dir, "files" => $files,
+ 'uploadMaxFilesize'=>$maxUploadFilesize,
+ 'maxHumanFilesize'=>$maxHumanFilesize
+ )));
} else {
- OCP\JSON::error(array("data" => array( "message" => "Could not delete:\n" . $filesWithError )));
+ OCP\JSON::error(array("data" => array( "message" => "Could not delete:\n" . $filesWithError,
+ 'uploadMaxFilesize'=>$maxUploadFilesize,
+ 'maxHumanFilesize'=>$maxHumanFilesize
+ )));
}
diff --git a/apps/files/ajax/getstoragestats.php b/apps/files/ajax/getstoragestats.php
new file mode 100644
index 00000000000..e55e346ed67
--- /dev/null
+++ b/apps/files/ajax/getstoragestats.php
@@ -0,0 +1,16 @@
+<?php
+
+// only need filesystem apps
+$RUNTIME_APPTYPES = array('filesystem');
+
+OCP\JSON::checkLoggedIn();
+
+$l=new OC_L10N('files');
+$maxUploadFilesize = OCP\Util::maxUploadFilesize($dir);
+$maxHumanFilesize = OCP\Util::humanFileSize($maxUploadFilesize);
+$maxHumanFilesize = $l->t('Upload') . ' max. ' . $maxHumanFilesize;
+
+// send back json
+OCP\JSON::success(array('data' => array('uploadMaxFilesize' => $maxUploadFilesize,
+ 'maxHumanFilesize' => $maxHumanFilesize
+)));
diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php
index 2a2d935da6c..93398019608 100644
--- a/apps/files/ajax/upload.php
+++ b/apps/files/ajax/upload.php
@@ -10,8 +10,17 @@ OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
$l=OC_L10N::get('files');
+// current max upload size
+$l=new OC_L10N('files');
+$maxUploadFilesize=OCP\Util::maxUploadFilesize($dir);
+$maxHumanFilesize=OCP\Util::humanFileSize($maxUploadFilesize);
+$maxHumanFilesize=$l->t('Upload') . ' max. '.$maxHumanFilesize;
+
if (!isset($_FILES['files'])) {
- OCP\JSON::error(array('data' => array( 'message' => $l->t( 'No file was uploaded. Unknown error' ))));
+ OCP\JSON::error(array('data' => array( 'message' => $l->t( 'No file was uploaded. Unknown error' ),
+ 'uploadMaxFilesize'=>$maxUploadFilesize,
+ 'maxHumanFilesize'=>$maxHumanFilesize
+ )));
exit();
}
@@ -28,7 +37,10 @@ foreach ($_FILES['files']['error'] as $error) {
UPLOAD_ERR_NO_TMP_DIR=>$l->t('Missing a temporary folder'),
UPLOAD_ERR_CANT_WRITE=>$l->t('Failed to write to disk'),
);
- OCP\JSON::error(array('data' => array( 'message' => $errors[$error] )));
+ OCP\JSON::error(array('data' => array( 'message' => $errors[$error],
+ 'uploadMaxFilesize'=>$maxUploadFilesize,
+ 'maxHumanFilesize'=>$maxHumanFilesize
+ )));
exit();
}
}
@@ -42,7 +54,9 @@ foreach($files['size'] as $size) {
$totalSize+=$size;
}
if($totalSize>OC_Filesystem::free_space($dir)) {
- OCP\JSON::error(array('data' => array( 'message' => $l->t( 'Not enough space available' ))));
+ OCP\JSON::error(array('data' => array( 'message' => $l->t( 'Not enough space available' ),
+ 'uploadMaxFilesize'=>$maxUploadFilesize,
+ 'maxHumanFilesize'=>$maxHumanFilesize)));
exit();
}
@@ -56,11 +70,19 @@ if(strpos($dir, '..') === false) {
if(is_uploaded_file($files['tmp_name'][$i]) and OC_Filesystem::fromTmpFile($files['tmp_name'][$i], $target)) {
$meta = OC_FileCache::get($target);
$id = OC_FileCache::getId($target);
+ // updated max file size after upload
+ $maxUploadFilesize=OCP\Util::maxUploadFilesize($dir);
+ $maxHumanFilesize=OCP\Util::humanFileSize($maxUploadFilesize);
+ $maxHumanFilesize=$l->t('Upload') . ' max. '.$maxHumanFilesize;
+
$result[]=array( 'status' => 'success',
'mime'=>$meta['mimetype'],
'size'=>$meta['size'],
'id'=>$id,
- 'name'=>basename($target));
+ 'name'=>basename($target),
+ 'uploadMaxFilesize'=>$maxUploadFilesize,
+ 'maxHumanFilesize'=>$maxHumanFilesize
+ );
}
}
OCP\JSON::encodedPrint($result);
@@ -69,4 +91,7 @@ if(strpos($dir, '..') === false) {
$error=$l->t( 'Invalid directory.' );
}
-OCP\JSON::error(array('data' => array('message' => $error )));
+OCP\JSON::error(array('data' => array('message' => $error,
+ 'uploadMaxFilesize'=>$maxUploadFilesize,
+ 'maxHumanFilesize'=>$maxHumanFilesize
+)));