Exemplo n.º 1
0
function fwrite(\Nov\CouchDb\Fs\Resource &$f, $data, $lenght = null)
{
    if (is_null($lenght)) {
        $out = $f->write($data);
    } else {
        $out = $f->write(mb_substr($data, 0, $lenght));
    }
    $path = $f->getPath();
    $fs = CouchDb\Fs::factory(FSCDB);
    $f = $fs->open($path);
}
Exemplo n.º 2
0
 public static function fs2cdb($path, $cdbId, $db = null)
 {
     echo $path . "<br/>";
     $ite = new \RecursiveDirectoryIterator($path);
     $finfo = finfo_open(FILEINFO_MIME);
     $fs = \Nov\CouchDb\Fs::factory($cdbId, $db);
     foreach (new \RecursiveIteratorIterator($ite) as $filename => $cur) {
         if (is_file($filename)) {
             echo "{$filename}<br/>";
             $relativePath = str_replace($path, null, $filename);
             $ct = finfo_file($finfo, $filename);
             $raw = file_get_contents($filename);
             $stat = self::alt_stat($filename);
             $fs->open($relativePath, true, true)->write($raw, $ct, array('stat' => $stat));
             echo "{$relativePath}<br/>";
             echo "";
             self::flush();
         }
     }
 }
Exemplo n.º 3
0
 /**
  * @param string $path
  * @return \Nov\CouchDb\Fs
  */
 private static function _getFs($path, $_url)
 {
     return \Nov\CouchDb\Fs::factory(FSCDB, $_url['host']);
 }
Exemplo n.º 4
0
<?php

use Nov\CouchDb\Fs;
use Nov\CouchDb\Fs\Exception;
require_once "Nov/Loader.php";
Nov\Loader::init();
echo "<pre>";
$fs = Fs::factory(NovConf::CDB1);
try {
    $fs->delete("/home/gonzalo/aaa.txt");
} catch (Exception\FileNotFound $e) {
    // **** Fs\Exception\FileNotFound
    echo $e->getMessage() . "\n";
}
try {
    echo "1";
    $fs->open("/home/gonzalo/aaa.txt", true)->write("asasasasasas", "application/octet-stream");
} catch (Exception\FileNotFound $e) {
    // **** Fs\Exception\FileNotFound
    echo $e->getMessage() . "\n";
} catch (Exception\WriteError $e) {
    // **** Fs\Exception\WriteError
    echo $e->getMessage() . "\n";
} catch (Exception $e) {
    echo $e->getMessage() . "\n";
}
$res = $fs->open("/home/gonzalo/aaa.txt");
echo $res->getLenght() . "\n";
echo $res->getContentType() . "\n";
echo "1 --- \n";
$to = uniqid();