19 declare(strict_types=1);
47 protected const DATA =
'data';
49 protected \ILIAS\ResourceStorage\StorageHandler\PathGenerator\PathGenerator
$path_generator;
50 protected \ILIAS\ResourceStorage\Identification\IdentificationGenerator
$id;
58 bool $determine_linking_possible =
false 63 if ($determine_linking_possible) {
70 $random_filename =
"test_" . random_int(10000, 99999);
74 $cleaner =
function () use ($original_filename, $linked_filename):
void {
76 $this->fs->delete($original_filename);
80 $this->fs->delete($linked_filename);
90 $this->fs->write($original_filename,
'data');
91 $stream = $this->fs->readStream($original_filename);
94 $original_absolute_path = $stream->getMetadata(
'uri');
95 $linked_absolute_path = dirname($original_absolute_path) .
"/" . $random_filename .
'_link';
99 $linking = @
link($original_absolute_path, $linked_absolute_path);
101 $unlinking = @unlink($original_absolute_path);
103 if ($linking && $unlinking && $this->fs->has($linked_filename)) {
141 $DIC->upload()->moveOneFileTo(
162 $original_path = $revision->
getStream()->getMetadata(
'uri');
163 if ($this->links_possible) {
166 unlink($original_path);
173 unlink($original_path);
208 if ($this->fs->has(
$path)) {
209 $this->fs->delete(
$path);
211 $this->fs->writeStream(
$path, $stream);
233 return $this->fs->has($this->
getFlavourPath($revision, $flavour));
241 if ($this->fs->has(
$path)) {
242 $this->fs->deleteDir(
$path);
245 foreach ($storabel_flavour->
getStreams() as $index => $stream) {
247 $this->fs->writeStream($index_path, $stream);
256 if ($this->fs->has(
$path)) {
257 $this->fs->deleteDir(
$path);
267 if (!$this->
hasFlavour($revision, $flavour)) {
270 foreach ($this->fs->finder()->in([
$path])->files()->sortByName()->getIterator() as $item) {
271 yield $this->fs->readStream($item->getPath());
295 $first_level = strtok($container_path,
"/");
296 if (!empty($first_level)) {
297 $full_first_level = $storage_path .
'/' . $first_level;
298 $number_of_files = $this->fs->finder()->files()->in([$full_first_level])->count();
299 if ($number_of_files === 0) {
300 $this->fs->deleteDir($full_first_level);
313 .
'/' . self::FLAVOUR_PATH_PREFIX
319 $this->fs->deleteDir($this->
getRevisionPath($revision) .
'/' . self::FLAVOUR_PATH_PREFIX);
334 return $this->path_generator->getPathFor($identification);
344 return $this->links_possible ?
'link' :
'rename';
__construct(Filesystem $fs, int $location=Location::STORAGE, bool $determine_linking_possible=false)
Class FileResourceHandler.
static createRelativePath(string $absolute_path)
Creates a relative path from an absolute path which starts with a valid storage location.
storeFlavour(Revision $revision, StorableFlavourDecorator $storabel_flavour)
hasFlavour(Revision $revision, Flavour $flavour)
Interface StorageResource.
const STORAGE
The filesystem outside of the ilias web root.
ILIAS ResourceStorage Identification IdentificationGenerator $id
streamReplacement(StreamReplacementRevision $revision)
getRevisionPath(Revision $revision)
This is the full path to a revision of a Resource, incl.
Class UploadedFileRevision.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const FLAVOUR_PATH_PREFIX
deleteFlavour(Revision $revision, Flavour $flavour)
cleanUpContainer(StorableResource $resource)
This checks if there are empty directories in the filesystem which can be deleted.
getContainerPathWithoutBase(ResourceIdentification $identification)
This is only the path of a ResourceIdentification inside the StorageLocation base path...
Class UploadedFileRevision.
Class UniqueIDIdentificationGenerator.
ILIAS ResourceStorage StorageHandler PathGenerator PathGenerator $path_generator
clearFlavours(Revision $revision)
storeStream(FileStreamRevision $revision)
getFlavourPath(Revision $revision, Flavour $flavour)
cloneRevision(CloneRevision $revision)
deleteResource(StorableResource $resource)
Class ResourceIdentification.
Class AbstractFileSystemStorageHandler.
Class UniqueIDIdentificationGenerator.
static deriveLocationFrom(string $absolute_path)
has(ResourceIdentification $identification)
getFlavourStreams(Revision $revision, Flavour $flavour)
getFullContainerPath(ResourceIdentification $identification)
This is the full path to the container of a ResourceIdentification (incl.
getBasePath(ResourceIdentification $identification)
getPersistingName()
Flavours are stored in the file system by the StroageHandler.
getStorageLocationBasePath()
This is the place in the filesystem where the containers (nested) get created.
link(string $caption, string $href, bool $new_viewport=false)
storeUpload(UploadedFileRevision $revision)
getIdentificationGenerator()
The base interface for all filesystem streams.
getStream(Revision $revision)
deleteRevision(Revision $revision)
getAbsoluteRevisionPath(Revision $revision)