Merge pull request #4363 from owncloud/fix-4355
Send mime-type for new files
This commit is contained in:
commit
b3b2b2d64c
|
@ -54,6 +54,8 @@ function progress($notification_code, $severity, $message, $message_code, $bytes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$target = $dir.'/'.$filename;
|
||||||
|
|
||||||
if($source) {
|
if($source) {
|
||||||
if(substr($source, 0, 8)!='https://' and substr($source, 0, 7)!='http://') {
|
if(substr($source, 0, 8)!='https://' and substr($source, 0, 7)!='http://') {
|
||||||
OCP\JSON::error(array("data" => array( "message" => "Not a valid source" )));
|
OCP\JSON::error(array("data" => array( "message" => "Not a valid source" )));
|
||||||
|
@ -62,7 +64,6 @@ if($source) {
|
||||||
|
|
||||||
$ctx = stream_context_create(null, array('notification' =>'progress'));
|
$ctx = stream_context_create(null, array('notification' =>'progress'));
|
||||||
$sourceStream=fopen($source, 'rb', false, $ctx);
|
$sourceStream=fopen($source, 'rb', false, $ctx);
|
||||||
$target=$dir.'/'.$filename;
|
|
||||||
$result=\OC\Files\Filesystem::file_put_contents($target, $sourceStream);
|
$result=\OC\Files\Filesystem::file_put_contents($target, $sourceStream);
|
||||||
if($result) {
|
if($result) {
|
||||||
$meta = \OC\Files\Filesystem::getFileInfo($target);
|
$meta = \OC\Files\Filesystem::getFileInfo($target);
|
||||||
|
@ -75,20 +76,24 @@ if($source) {
|
||||||
$eventSource->close();
|
$eventSource->close();
|
||||||
exit();
|
exit();
|
||||||
} else {
|
} else {
|
||||||
|
$success = false;
|
||||||
if($content) {
|
if($content) {
|
||||||
if(\OC\Files\Filesystem::file_put_contents($dir.'/'.$filename, $content)) {
|
$success = \OC\Files\Filesystem::file_put_contents($target, $content);
|
||||||
$meta = \OC\Files\Filesystem::getFileInfo($dir.'/'.$filename);
|
} else {
|
||||||
$id = $meta['fileid'];
|
$success = \OC\Files\Filesystem::touch($target);
|
||||||
OCP\JSON::success(array("data" => array('content'=>$content, 'id' => $id)));
|
}
|
||||||
exit();
|
|
||||||
}
|
if($success) {
|
||||||
}elseif(\OC\Files\Filesystem::touch($dir . '/' . $filename)) {
|
$meta = \OC\Files\Filesystem::getFileInfo($target);
|
||||||
$meta = \OC\Files\Filesystem::getFileInfo($dir.'/'.$filename);
|
|
||||||
$id = $meta['fileid'];
|
$id = $meta['fileid'];
|
||||||
OCP\JSON::success(array("data" => array('content'=>$content, 'id' => $id, 'mime' => $meta['mimetype'])));
|
$mime = $meta['mimetype'];
|
||||||
|
OCP\JSON::success(array('data' => array(
|
||||||
|
'id' => $id,
|
||||||
|
'mime' => $mime,
|
||||||
|
'content' => $content,
|
||||||
|
)));
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
OCP\JSON::error(array("data" => array( "message" => "Error when creating the file" )));
|
OCP\JSON::error(array("data" => array( "message" => "Error when creating the file" )));
|
||||||
|
|
Loading…
Reference in New Issue