summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2012-09-26 13:24:41 +0200
committerRobin Appelman <icewind@owncloud.com>2012-09-26 13:25:11 +0200
commitcfbca40fbee14812a69ceb5fda4db7c23645fa9c (patch)
tree5679da072aef3cfaa52d3f7783c1dc7adc939471
parent2c00f8c850e3b481d270f23e99d572271f2e6f73 (diff)
downloadnextcloud-server-cfbca40fbee14812a69ceb5fda4db7c23645fa9c.tar.gz
nextcloud-server-cfbca40fbee14812a69ceb5fda4db7c23645fa9c.zip
fix sharing for newly uploaded or created files
-rw-r--r--apps/files/ajax/newfile.php14
-rw-r--r--apps/files/ajax/upload.php3
-rw-r--r--apps/files/js/files.js9
3 files changed, 17 insertions, 9 deletions
diff --git a/apps/files/ajax/newfile.php b/apps/files/ajax/newfile.php
index 495c8212163..c2d65d718c5 100644
--- a/apps/files/ajax/newfile.php
+++ b/apps/files/ajax/newfile.php
@@ -66,8 +66,10 @@ if($source) {
$target=$dir.'/'.$filename;
$result=OC_Filesystem::file_put_contents($target, $sourceStream);
if($result) {
- $mime=OC_Filesystem::getMimetype($target);
- $eventSource->send('success', array('mime'=>$mime, 'size'=>OC_Filesystem::filesize($target)));
+ $meta = OC_FileCache::get($target);
+ $mime=$meta['mimetype'];
+ $id = OC_FileCache::getId($target);
+ $eventSource->send('success', array('mime'=>$mime, 'size'=>OC_Filesystem::filesize($target), 'id' => $id));
} else {
$eventSource->send('error', "Error while downloading ".$source. ' to '.$target);
}
@@ -76,11 +78,15 @@ if($source) {
} else {
if($content) {
if(OC_Filesystem::file_put_contents($dir.'/'.$filename, $content)) {
- OCP\JSON::success(array("data" => array('content'=>$content)));
+ $meta = OC_FileCache::get($dir.'/'.$filename);
+ $id = OC_FileCache::getId($dir.'/'.$filename);
+ OCP\JSON::success(array("data" => array('content'=>$content, 'id' => $id)));
exit();
}
}elseif(OC_Files::newFile($dir, $filename, 'file')) {
- OCP\JSON::success(array("data" => array('content'=>$content)));
+ $meta = OC_FileCache::get($dir.'/'.$filename);
+ $id = OC_FileCache::getId($dir.'/'.$filename);
+ OCP\JSON::success(array("data" => array('content'=>$content, 'id' => $id)));
exit();
}
}
diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php
index fb3e277a215..a4dcd80a2e2 100644
--- a/apps/files/ajax/upload.php
+++ b/apps/files/ajax/upload.php
@@ -50,7 +50,8 @@ if(strpos($dir, '..') === false) {
$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);
- $result[]=array( "status" => "success", 'mime'=>$meta['mimetype'],'size'=>$meta['size'],'name'=>basename($target));
+ $id = OC_FileCache::getId($target);
+ $result[]=array( "status" => "success", 'mime'=>$meta['mimetype'],'size'=>$meta['size'], 'id'=>$id, 'name'=>basename($target));
}
}
OCP\JSON::encodedPrint($result);
diff --git a/apps/files/js/files.js b/apps/files/js/files.js
index ec2f159b4ca..0c00fe8c922 100644
--- a/apps/files/js/files.js
+++ b/apps/files/js/files.js
@@ -336,7 +336,7 @@ $(document).ready(function() {
if(response[0] != undefined && response[0].status == 'success') {
var file=response[0];
delete uploadingFiles[file.name];
- $('tr').filterAttr('data-file',file.name).data('mime',file.mime);
+ $('tr').filterAttr('data-file',file.name).data('mime',file.mime).data('id',file.id);
var size = $('tr').filterAttr('data-file',file.name).find('td.filesize').text();
if(size==t('files','Pending')){
$('tr').filterAttr('data-file',file.name).find('td.filesize').text(file.size);
@@ -366,7 +366,7 @@ $(document).ready(function() {
if(response[0] != undefined && response[0].status == 'success') {
var file=response[0];
delete uploadingFiles[file.name];
- $('tr').filterAttr('data-file',file.name).data('mime',file.mime);
+ $('tr').filterAttr('data-file',file.name).data('mime',file.mime).data('id',file.id);
var size = $('tr').filterAttr('data-file',file.name).find('td.filesize').text();
if(size==t('files','Pending')){
$('tr').filterAttr('data-file',file.name).find('td.filesize').text(file.size);
@@ -512,7 +512,7 @@ $(document).ready(function() {
var date=new Date();
FileList.addFile(name,0,date,false,hidden);
var tr=$('tr').filterAttr('data-file',name);
- tr.data('mime','text/plain');
+ tr.data('mime','text/plain').data('id',result.data.id);
getMimeIcon('text/plain',function(path){
tr.find('td.filename').attr('style','background-image:url('+path+')');
});
@@ -560,11 +560,12 @@ $(document).ready(function() {
eventSource.listen('success',function(data){
var mime=data.mime;
var size=data.size;
+ var id=data.id;
$('#uploadprogressbar').fadeOut();
var date=new Date();
FileList.addFile(localName,size,date,false,hidden);
var tr=$('tr').filterAttr('data-file',localName);
- tr.data('mime',mime);
+ tr.data('mime',mime).data('id',id);
getMimeIcon(mime,function(path){
tr.find('td.filename').attr('style','background-image:url('+path+')');
});