summaryrefslogtreecommitdiffstats
path: root/apps/files/ajax
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2013-08-17 08:42:49 -0700
committerThomas Müller <thomas.mueller@tmit.eu>2013-08-17 08:42:49 -0700
commit12f4494de02457d51004ca6a82c1b2160189819f (patch)
treeed801705ca0425deef6d679e3f3f7bd5c772944e /apps/files/ajax
parent6ae6dc00e5758a7c08cc1e45ba75ca5835a9d22c (diff)
parent57f7ff2dbdbef977483c0078048181ea1b7630f2 (diff)
downloadnextcloud-server-12f4494de02457d51004ca6a82c1b2160189819f.tar.gz
nextcloud-server-12f4494de02457d51004ca6a82c1b2160189819f.zip
Merge pull request #4339 from owncloud/mimetype-defaults
Add the option to provide templates for newly created files
Diffstat (limited to 'apps/files/ajax')
-rw-r--r--apps/files/ajax/newfile.php8
1 files changed, 8 insertions, 0 deletions
diff --git a/apps/files/ajax/newfile.php b/apps/files/ajax/newfile.php
index 8c1aad8668c..d224e79d01b 100644
--- a/apps/files/ajax/newfile.php
+++ b/apps/files/ajax/newfile.php
@@ -77,6 +77,12 @@ if($source) {
exit();
} else {
$success = false;
+ if (!$content) {
+ $templateManager = OC_Helper::getFileTemplateManager();
+ $mimeType = OC_Helper::getMimeType($target);
+ $content = $templateManager->getTemplate($mimeType);
+ }
+
if($content) {
$success = \OC\Files\Filesystem::file_put_contents($target, $content);
} else {
@@ -87,9 +93,11 @@ if($source) {
$meta = \OC\Files\Filesystem::getFileInfo($target);
$id = $meta['fileid'];
$mime = $meta['mimetype'];
+ $size = $meta['size'];
OCP\JSON::success(array('data' => array(
'id' => $id,
'mime' => $mime,
+ 'size' => $size,
'content' => $content,
)));
exit();