summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2013-08-14 09:46:10 -0700
committerThomas Müller <thomas.mueller@tmit.eu>2013-08-14 09:46:10 -0700
commitb3b2b2d64c626f9c6725be979d200c509b080365 (patch)
treeb92e53165a287ef959d8a2d8726e464600e1d370
parent435e63b5eef345a996618dbc0f4e4c9d202de7ec (diff)
parentbeb27168de3e81f71c894ee64561d029b3b2b02c (diff)
downloadnextcloud-server-b3b2b2d64c626f9c6725be979d200c509b080365.tar.gz
nextcloud-server-b3b2b2d64c626f9c6725be979d200c509b080365.zip
Merge pull request #4363 from owncloud/fix-4355
Send mime-type for new files
-rw-r--r--apps/files/ajax/newfile.php27
1 files changed, 16 insertions, 11 deletions
diff --git a/apps/files/ajax/newfile.php b/apps/files/ajax/newfile.php
index 8548fc95ddf..8c1aad8668c 100644
--- a/apps/files/ajax/newfile.php
+++ b/apps/files/ajax/newfile.php
@@ -54,6 +54,8 @@ function progress($notification_code, $severity, $message, $message_code, $bytes
}
}
+$target = $dir.'/'.$filename;
+
if($source) {
if(substr($source, 0, 8)!='https://' and substr($source, 0, 7)!='http://') {
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'));
$sourceStream=fopen($source, 'rb', false, $ctx);
- $target=$dir.'/'.$filename;
$result=\OC\Files\Filesystem::file_put_contents($target, $sourceStream);
if($result) {
$meta = \OC\Files\Filesystem::getFileInfo($target);
@@ -75,20 +76,24 @@ if($source) {
$eventSource->close();
exit();
} else {
+ $success = false;
if($content) {
- if(\OC\Files\Filesystem::file_put_contents($dir.'/'.$filename, $content)) {
- $meta = \OC\Files\Filesystem::getFileInfo($dir.'/'.$filename);
- $id = $meta['fileid'];
- OCP\JSON::success(array("data" => array('content'=>$content, 'id' => $id)));
- exit();
- }
- }elseif(\OC\Files\Filesystem::touch($dir . '/' . $filename)) {
- $meta = \OC\Files\Filesystem::getFileInfo($dir.'/'.$filename);
+ $success = \OC\Files\Filesystem::file_put_contents($target, $content);
+ } else {
+ $success = \OC\Files\Filesystem::touch($target);
+ }
+
+ if($success) {
+ $meta = \OC\Files\Filesystem::getFileInfo($target);
$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();
}
}
-
OCP\JSON::error(array("data" => array( "message" => "Error when creating the file" )));