public function moveTo(MOXMAN_Vfs_IFile $dest) { if ($dest instanceof MOXMAN_Ftp_File) { ftp_rename($this->fileSystem->getConnection(), $this->getInternalPath(), $dest->getInternalPath()); } else { $this->copyTo($dest); $this->delete(true); } }
public function moveTo(MOXMAN_Vfs_IFile $dest) { $this->fileSystem->getCache()->remove($this->getPath()); ftp_rename($this->fileSystem->getConnection(), $this->getInternalPath(), $dest->getInternalPath()); }
/** * Copies this file to the specified file instance. * * @param MCE_File $dest File to copy to. */ public function copyTo(MOXMAN_Vfs_IFile $dest) { if ($this->exists() && $this->isDirectory()) { if (!$this->isFileOrEmptyDir()) { throw new MOXMAN_Exception("Copy non empty folders not supported by Azure."); } else { $dest->mkdir(); return; } } if ($dest instanceof MOXMAN_Azure_File) { $containerUrl = MOXMAN_Util_PathUtils::combine($this->fileSystem->getContainerOption("account"), $this->fileSystem->getContainerOption("name")); $fromUrl = "/" . MOXMAN_Util_PathUtils::combine($containerUrl, $this->getInternalPath()); $request = $this->getFileSystem()->createRequest(array("method" => "PUT", "path" => $dest->getInternalPath(), "headers" => array("x-ms-copy-source" => $fromUrl, "Content-Length" => 0))); $this->getFileSystem()->sendRequest($request); } else { $fromStream = $this->open("rb"); $toStream = $dest->open("wb"); while (($buff = $fromStream->read(8192)) !== "") { $toStream->write($buff); } $fromStream->close(); $toStream->close(); } }
/** * Sends the specified file to the client by streaming it. * * @param MOXMAN_Vfs_IFile $file File to stream to client. * @param Boolean $download State if the file should be downloaded or not by the client. */ public function sendFile(MOXMAN_Vfs_IFile $file, $download = false) { // Check if the file is a local file is so use the faster method if ($file instanceof MOXMAN_Vfs_Local_File) { $this->sendLocalFile($file->getInternalPath(), $download); return; } // Check if the remote file system has a local temp path $localTempPath = MOXMAN::getFileSystemManager()->getLocalTempPath($file); if (file_exists($localTempPath)) { $this->sendLocalFile($localTempPath, $download); return; } if ($download) { $this->disableCache(); $this->setHeader("Content-type", "application/octet-stream"); $this->setHeader("Content-Disposition", "attachment; filename=\"" . $file->getName() . "\""); } else { $this->setHeader("Content-type", MOXMAN_Util_Mime::get($file->getName())); } // Non local file system then read and stream $stream = $file->open(MOXMAN_Vfs_IFileStream::READ); if ($stream) { // Read chunk by chunk and stream it while (($buff = $stream->read()) !== "") { $this->sendContent($buff); } $stream->close(); } }
/** * Saves the image to the specified file. * * @param stirng $file File instance to save image to. * @param int $quality Image quality for jpegs. */ public function saveToFile(MOXMAN_Vfs_IFile $file, $quality = 90) { if ($file instanceof MOXMAN_Vfs_Local_File) { return $this->save($file->getInternalPath()); } // Load image into RAM then write that to file // TODO: Replace this once PHP get proper buffers for GD $stream = $file->open(MOXMAN_Vfs_IFileStream::WRITE); $stream->write($this->getAsString(MOXMAN_Util_PathUtils::getExtension($file->getName()), $quality)); $stream->close(); }
/** * Copies this file to the specified file instance. * * @param MCE_File $dest File to copy to. */ public function copyTo(MOXMAN_Vfs_IFile $dest) { if ($this->exists() && $this->isDirectory()) { if (!$this->isFileOrEmptyDir()) { throw new MOXMAN_Exception("Copy non empty folders not supported by S3."); } else { $dest->mkdir(); return; } } if ($dest instanceof MOXMAN_AmazonS3_File) { $fromPath = $this->getInternalPath(); $toPath = $dest->getInternalPath(); if ($this->isDirectory()) { $fromPath .= "/"; $toPath .= "/"; } $this->getFileSystem()->getClient()->copy($fromPath, $toPath); $dest->removeStatCache(); } else { $fromStream = $this->open("rb"); $toStream = $dest->open("wb"); while (($buff = $fromStream->read(8192)) !== "") { $toStream->write($buff); } $fromStream->close(); $toStream->close(); } }