get the right metadata and file id if a file was uploaded to a Shared folder

This commit is contained in:
Björn Schießle 2012-11-14 14:55:22 +01:00
parent bcb9cf3c06
commit cb55229c1e
1 changed files with 13 additions and 2 deletions

View File

@ -49,8 +49,19 @@ if(strpos($dir, '..') === false) {
for($i=0;$i<$fileCount;$i++) {
$target = OCP\Files::buildNotExistingFileName(stripslashes($dir), $files['name'][$i]);
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);
if ( OC_App::isEnabled('files_sharing') && !strncmp($target, '/Shared/', 8)) {
$source = OC_Files_Sharing_Util::getSourcePath(str_replace('/Shared/', '', $target));
$parts = explode('/', $source, 4);
$root = '/'.$parts[1].'/files';
$path = '/'.$parts[3];
} else {
$path = $target;
$root = false;
}
$meta = OC_FileCache::get($path, $root);
$id = OC_FileCache::getId($path, $root);
$result[]=array( "status" => "success", 'mime'=>$meta['mimetype'],'size'=>$meta['size'], 'id'=>$id, 'name'=>basename($target));
}
}