Pimcore\Model\Asset::setStream PHP Method

setStream() public method

public setStream ( $stream )
$stream
    public function setStream($stream)
    {
        // close existing stream
        $this->closeStream();
        if (is_resource($stream)) {
            $this->setDataChanged(true);
            $this->stream = $stream;
            rewind($this->stream);
        } elseif (is_null($stream)) {
            $this->stream = null;
        }
        return $this;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * @param resource $data
  * @throws DAV\Exception\Forbidden
  * @throws \Exception
  */
 function put($data)
 {
     if ($this->asset->isAllowed("publish")) {
         // read from resource -> default for SabreDAV
         $tmpFile = PIMCORE_SYSTEM_TEMP_DIRECTORY . "/asset-dav-tmp-file-" . uniqid();
         file_put_contents($tmpFile, $data);
         $file = fopen($tmpFile, "r+");
         $user = AdminTool::getCurrentUser();
         $this->asset->setUserModification($user->getId());
         $this->asset->setStream($file);
         $this->asset->save();
         fclose($file);
         unlink($tmpFile);
     } else {
         throw new DAV\Exception\Forbidden();
     }
 }