6 require_once
'Modules/File/classes/class.ilObjFile.php';
40 parent::__construct($a_obj, $repo_helper, $dav_helper);
67 if ($this->repo_helper->checkAccess(
'write', $this->getRefId())) {
72 throw new Exception\Forbidden(
"Permission denied. No write access for this file");
85 if ($this->repo_helper->checkAccess(
"read", $this->obj->getRefId())) {
87 if (file_exists($file)) {
88 return fopen($file,
'r');
90 throw new Exception\NotFound(
"File not found");
94 throw new Exception\Forbidden(
"Permission denied. No read access for this file");
116 return $this->obj->guessFileType();
154 return $this->obj->getFileSize();
165 if ($this->dav_helper->isValidFileNameWithValidFileExtension($a_name)) {
166 parent::setName($a_name);
168 throw new Exception\Forbidden(
"Invalid file extension");
187 $this->obj->setFileName($this->
getName());
191 if (!file_exists($file_dest_path)) {
196 if (is_resource($a_data)) {
198 } elseif (is_string($a_data)) {
201 ilLoggerFactory::getLogger(
'WebDAV')->warning(get_class($this) .
' ' . $this->obj->getTitle() .
" -> invalid upload data sent");
202 throw new Exception\BadRequest(
'Invalid put data sent');
209 include_once(
"./Services/Utilities/classes/class.ilMimeTypeUtil.php");
211 $this->obj->setFileSize($written_length);
212 if ($this->obj->update() && $this->obj->getMaxVersion() > 1) {
229 $write_stream =
fopen($file_dest_path,
'w');
230 while (!feof($a_data)) {
231 if (
false === ($written = fwrite($write_stream, fread($a_data, 4096)))) {
232 fclose($write_stream);
233 throw new Exception\Forbidden(
'Forbidden to write file');
235 $written_length += $written;
238 ilLoggerFactory::getLogger(
'WebDAV')->error(
"Error on uploading {$this->obj->getTitle()} to path $file_dest_path with message: " . $e->getMessage());
241 fclose($write_stream);
244 return $written_length;
257 $write_stream =
fopen($file_dest_path,
'w');
258 $written_length = fwrite($write_stream, $a_data);
259 fclose($write_stream);
260 if ($written_length ===
false && strlen($a_data) > 0) {
261 throw new Exception\Forbidden(
'Forbidden to write file');
263 return $written_length;
268 return $this->obj->getDirectory($this->obj->getVersion());
294 if ($vrs[0] ==
false) {
295 ilLoggerFactory::getLogger(
'WebDAV')->error(get_class($this) .
' ' . $this->obj->getTitle() .
" -> virus found on '$file_dest_path'!");
296 unlink($file_dest_path);
297 $this->obj->delete();
298 throw new Exception\Forbidden(
'Virus found!');
309 if ($this->obj->getFileSize() > 0) {
311 $this->obj->setVersion($this->obj->getMaxVersion() + 1);
312 $this->obj->setMaxVersion($this->obj->getMaxVersion() + 1);
322 ilHistory::_createEntry($this->obj->getId(),
"new_version", $this->obj->getTitle() .
"," . $this->obj->getVersion() .
"," . $this->obj->getMaxVersion());
323 $this->obj->addNewsNotification(
"file_updated");
static makeDirParents($a_dir)
Create a new directory and all parent directories.
getSize()
Returns the size of the node, in bytes.
static virusHandling($a_file, $a_orig_name="", $a_clean=true)
scan file for viruses and clean files if possible
getPathToFile()
This method is called in 2 use cases:
put($data)
Replaces the contents of the file.
Class ilWebDAVRepositoryHelper.
static lookupMimeType($path_to_file, $fallback=self::APPLICATION__OCTET_STREAM, $a_external=null)
static _createEntry( $a_obj_id, $a_action, $a_info_params="", $a_obj_type="", $a_user_comment="", $a_update_last=false)
Creates a new history entry for an object.
fileUploadWithStream($a_data, string $file_dest_path)
Write given data (as Resource) to the given file.
Class ilWebDAVObjDAVHelper.
setObjValuesForNewFileVersion()
Set object values for a new file version.
createHistoryAndNotificationForObjUpdate()
Create history entry and a news notification for file object update.
handleFileUpload($a_data)
Handle uploaded file.
This interface represents a file in the directory tree.
fileUploadWithString(string $a_data, string $file_dest_path)
Write given data (as string) to the given file.
static getLogger($a_component_id)
Get component logger.
getName()
Returns title of file object.
__construct(ilObjFile $a_obj, ilWebDAVRepositoryHelper $repo_helper, ilWebDAVObjDAVHelper $dav_helper)
ilObjFileDAV represents the WebDAV-Interface to an ILIAS-Object
checkForVirus(string $file_dest_path)
getETag()
Returns the ETag for a file.
static getValidFilename($a_filename)
Get valid filename.
getContentType()
Returns the mime-type for a file.