get the right metadata and file id if a file was uploaded to a Shared folder
This commit is contained in:
parent
bcb9cf3c06
commit
cb55229c1e
|
@ -49,8 +49,19 @@ if(strpos($dir, '..') === false) {
|
||||||
for($i=0;$i<$fileCount;$i++) {
|
for($i=0;$i<$fileCount;$i++) {
|
||||||
$target = OCP\Files::buildNotExistingFileName(stripslashes($dir), $files['name'][$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)) {
|
if(is_uploaded_file($files['tmp_name'][$i]) and OC_Filesystem::fromTmpFile($files['tmp_name'][$i], $target)) {
|
||||||
$meta = OC_FileCache::get($target);
|
if ( OC_App::isEnabled('files_sharing') && !strncmp($target, '/Shared/', 8)) {
|
||||||
$id = OC_FileCache::getId($target);
|
$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));
|
$result[]=array( "status" => "success", 'mime'=>$meta['mimetype'],'size'=>$meta['size'], 'id'=>$id, 'name'=>basename($target));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue