Ejemplo n.º 1
0
 public function open()
 {
     TempFileObject::setPath('/tmp');
     TempFileObject::setFilenameLength(100);
     parent::open();
     unset($this->file);
     $this->file = new TempFileObject('w+');
 }
Ejemplo n.º 2
0
 /**
  * Convert all the possible elements from which you can import content
  * to a resource.
  *
  * @param string|resource $res
  * @return TempFileObject
  */
 protected function convertToResource($res)
 {
     $file = new TempFileObject($this->options['tmp'] . '/' . StringUtils::randString(50));
     switch (true) {
         case $res instanceof FileObject:
             $file->write($res->read());
             unset($res);
             break;
         case is_resource($res):
             $file->write(stream_get_contents($res));
             break;
         case file_exists($res):
         case filter_var($res, FILTER_VALIDATE_URL):
             $file->write(stream_get_contents(fopen($res, 'r')));
             break;
         default:
             $file->write($res);
     }
     $file->rewind();
     return $file;
 }