summaryrefslogtreecommitdiffstats
path: root/apps/files/ajax/upload.php
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2013-10-28 20:22:06 +0100
committerVincent Petry <pvince81@owncloud.com>2014-04-02 15:33:47 +0200
commit0be9de5df558232e12e2f582af5d08e1f488ba90 (patch)
treede37dea2e23dd28f631948295979980ec774027f /apps/files/ajax/upload.php
parent268206cec55921d2d0309469ebd5d9533e4f79ee (diff)
downloadnextcloud-server-0be9de5df558232e12e2f582af5d08e1f488ba90.tar.gz
nextcloud-server-0be9de5df558232e12e2f582af5d08e1f488ba90.zip
Files, trashbin, public apps use ajax/JSON for the file list
Files app: - removed file list template, now rendering list from JSON response - FileList.addFile/addDir is now FileList.add() and takes a JS map with all required arguments instead of having a long number of function arguments - added unit tests for many FileList operations - fixed newfile.php, newfolder.php and rename.php to return the file's full JSON on success - removed obsolete/unused undo code - removed download_url / loading options, now using Files.getDownloadUrl() for that - server side now uses Helper::getFileInfo() to prepare file JSON response - previews are now client-side only Breadcrumbs are now JS only: - Added BreadCrumb class to handle breadcrumb rendering and events - Added unit test for BreadCrumb class - Moved all relevant JS functions to the BreadCrumb class Public page now uses ajax to load the file list: - Added Helper class in sharing app to make it easier to authenticate and retrieve the file's real path - Added ajax/list.php to retrieve the file list - Fixed FileActions and FileList to work with the ajax list Core: - Fixed file picker dialog to use the same list format as files app
Diffstat (limited to 'apps/files/ajax/upload.php')
-rw-r--r--apps/files/ajax/upload.php47
1 files changed, 21 insertions, 26 deletions
diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php
index 4ed51c52775..b21a9dfba2e 100644
--- a/apps/files/ajax/upload.php
+++ b/apps/files/ajax/upload.php
@@ -20,6 +20,10 @@ if (empty($_POST['dirToken'])) {
die();
}
} else {
+ // TODO: ideally this code should be in files_sharing/ajax/upload.php
+ // and the upload/file transfer code needs to be refactored into a utility method
+ // that could be used there
+
// return only read permissions for public upload
$allowedPermissions = OCP\PERMISSION_READ;
$public_directory = !empty($_POST['subdir']) ? $_POST['subdir'] : '/';
@@ -141,19 +145,14 @@ if (strpos($dir, '..') === false) {
$error = $l->t('The target folder has been moved or deleted.');
$errorCode = 'targetnotfound';
} else {
- $result[] = array('status' => 'success',
- 'mime' => $meta['mimetype'],
- 'mtime' => $meta['mtime'],
- 'size' => $meta['size'],
- 'id' => $meta['fileid'],
- 'name' => basename($target),
- 'etag' => $meta['etag'],
- 'originalname' => $files['tmp_name'][$i],
- 'uploadMaxFilesize' => $maxUploadFileSize,
- 'maxHumanFilesize' => $maxHumanFileSize,
- 'permissions' => $meta['permissions'] & $allowedPermissions,
- 'directory' => $directory,
- );
+ $data = \OCA\Files\Helper::formatFileInfo($meta);
+ $data['status'] = 'success';
+ $data['originalname'] = $files['tmp_name'][$i];
+ $data['uploadMaxFilesize'] = $maxUploadFileSize;
+ $data['maxHumanFilesize'] = $maxHumanFileSize;
+ $data['permissions'] = $meta['permissions'] & $allowedPermissions;
+ $data['directory'] = $directory;
+ $result[] = $data;
}
} else {
@@ -169,19 +168,15 @@ if (strpos($dir, '..') === false) {
if ($meta === false) {
$error = $l->t('Upload failed. Could not get file info.');
} else {
- $result[] = array('status' => 'existserror',
- 'mime' => $meta['mimetype'],
- 'mtime' => $meta['mtime'],
- 'size' => $meta['size'],
- 'id' => $meta['fileid'],
- 'name' => basename($target),
- 'etag' => $meta['etag'],
- 'originalname' => $files['tmp_name'][$i],
- 'uploadMaxFilesize' => $maxUploadFileSize,
- 'maxHumanFilesize' => $maxHumanFileSize,
- 'permissions' => $meta['permissions'] & $allowedPermissions,
- 'directory' => $directory,
- );
+ $data = \OCA\Files\Helper::formatFileInfo($meta);
+ $data['permissions'] = $data['permissions'] & $allowedPermissions;
+ $data['status'] = 'existserror';
+ $data['originalname'] = $files['tmp_name'][$i];
+ $data['uploadMaxFilesize'] = $maxUploadFileSize;
+ $data['maxHumanFilesize'] = $maxHumanFileSize;
+ $data['permissions'] = $meta['permissions'] & $allowedPermissions;
+ $data['directory'] = $directory;
+ $result[] = $data;
}
}
}