implement file_put_contents with stream data using fopen
This commit is contained in:
parent
6a8364c3ff
commit
c121a1a1e7
|
@ -70,11 +70,7 @@ class OC_FileProxy_Encryption extends OC_FileProxy{
|
||||||
|
|
||||||
public function preFile_put_contents($path,&$data){
|
public function preFile_put_contents($path,&$data){
|
||||||
if(self::shouldEncrypt($path)){
|
if(self::shouldEncrypt($path)){
|
||||||
if (is_resource($data)) {
|
if (!is_resource($data)) {//stream put contents should have been converter to fopen
|
||||||
$id=md5($path);
|
|
||||||
OC_CryptStream::$sourceStreams[$id]=array('path'=>$path,'stream'=>$data);
|
|
||||||
$data=fopen('crypt://streams/'.$id,'r');
|
|
||||||
}else{
|
|
||||||
$data=OC_Crypt::blockEncrypt($data);
|
$data=OC_Crypt::blockEncrypt($data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -163,8 +163,22 @@ class OC_FilesystemView {
|
||||||
return $this->basicOperation('file_get_contents',$path,array('read'));
|
return $this->basicOperation('file_get_contents',$path,array('read'));
|
||||||
}
|
}
|
||||||
public function file_put_contents($path,$data){
|
public function file_put_contents($path,$data){
|
||||||
|
if(is_resource($data)){//not having to deal with streams in file_put_contents makes life easier
|
||||||
|
$target=$this->fopen($path,'w');
|
||||||
|
if($target){
|
||||||
|
while(!feof($data)){
|
||||||
|
fwrite($target,fread($data,8192));
|
||||||
|
}
|
||||||
|
fclose($target);
|
||||||
|
fclose($data);
|
||||||
|
return true;
|
||||||
|
}else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
return $this->basicOperation('file_put_contents',$path,array('create','write'),$data);
|
return $this->basicOperation('file_put_contents',$path,array('create','write'),$data);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public function unlink($path){
|
public function unlink($path){
|
||||||
return $this->basicOperation('unlink',$path,array('delete'));
|
return $this->basicOperation('unlink',$path,array('delete'));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue