ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilRestFileStorage Class Reference

File storage handling. More...

+ Inheritance diagram for ilRestFileStorage:
+ Collaboration diagram for ilRestFileStorage:

Public Member Functions

 __construct ()
 Constructor.
 getFile ($name)
 Get file by md5 hash.
 createFile ()
 Get file by md5 hash.
 storeFileForRest ($content)
 getStoredFilePath ($tmpname)
 deleteDeprecated ()
 Delete deprecated files.
- Public Member Functions inherited from ilFileSystemStorage
 __construct ($a_storage_type, $a_path_conversion, $a_container_id)
 Constructor.
 getContainerId ()
 create ()
 Create directory.
 getAbsolutePath ()
 Get absolute path of storage directory.
 writeToFile ($a_data, $a_absolute_path)
 Write data to file.
 deleteFile ($a_abs_name)
 Delete file.
 deleteDirectory ($a_abs_name)
 Delete directory.
 delete ()
 Delete complete directory.
 copyFile ($a_from, $a_to)
 Copy files.
 appendToPath ($a_appendix)
 getStorageType ()
 getPath ()
 Get path.
 __construct ($a_storage_type, $a_path_conversion, $a_container_id)
 Constructor.
 create ()
 Create directory.
 getAbsolutePath ()
 Get absolute path of storage directory.
 getShortPath ()
 rename ($from, $to)

Data Fields

const AVAILABILITY_IN_DAYS = 1
- Data Fields inherited from ilFileSystemStorage
const STORAGE_WEB = 1
const STORAGE_DATA = 2
const STORAGE_SECURED = 3
const FACTOR = 100
const MAX_EXPONENT = 3
const SECURED_DIRECTORY = "sec"

Protected Member Functions

 getPathPrefix ()
 Get path prefix.
 getPathPostfix ()
 Get path prefix.
 init ()
 init and create directory

Additional Inherited Members

- Static Public Member Functions inherited from ilFileSystemStorage
static _createPathFromId ($a_container_id, $a_name)
 Create a path from an id: e.g 12345 will be converted to 12/34/<name>_5.
 _copyDirectory ($a_source, $a_target)
 Copy directory and all contents.
static _createPathFromId ($a_container_id, $a_name)
 Create a path from an id: e.g 12345 will be converted to 12/34/<name>_5.
- Protected Attributes inherited from ilFileSystemStorage
 $path

Detailed Description

File storage handling.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e $Id$

Definition at line 12 of file class.ilRestFileStorage.php.

Constructor & Destructor Documentation

ilRestFileStorage::__construct ( )

Constructor.

Definition at line 21 of file class.ilRestFileStorage.php.

References ilFileSystemStorage\STORAGE_DATA.

Member Function Documentation

ilRestFileStorage::createFile ( )

Get file by md5 hash.

Parameters
<type>$name

Definition at line 79 of file class.ilRestFileStorage.php.

References $GLOBALS, ilFileSystemStorage\$path, Slim\getInstance(), ilFileSystemStorage\getPath(), ilUtil\ilTempnam(), and ilFileSystemStorage\writeToFile().

{
$request = Slim::getInstance()->request();
$body = $request->post("content");
$tmpname = ilUtil::ilTempnam();
$path = $this->getPath().'/'.basename($tmpname);
$this->writeToFile($body, $path);
$return = basename($tmpname);
$GLOBALS['ilLog']->write(__METHOD__.' Writing to path '.$path);
Slim::getInstance()->response()->header('Content-Type', 'application/json');
Slim::getInstance()->response()->body($return);
}

+ Here is the call graph for this function:

ilRestFileStorage::deleteDeprecated ( )

Delete deprecated files.

Definition at line 113 of file class.ilRestFileStorage.php.

References $file, $GLOBALS, and ilFileSystemStorage\getPath().

{
$max_age = time() - self::AVAILABILITY_IN_DAYS * 24 * 60 * 60;
$ite = new DirectoryIterator($this->getPath());
foreach($ite as $file)
{
if($file->getCTime() <= $max_age)
{
try {
@unlink($file->getPathname());
}
catch(Exception $e) {
$GLOBALS['ilLog']->write(__METHOD__.' '. $e->getMessage());
}
}
}
}

+ Here is the call graph for this function:

ilRestFileStorage::getFile (   $name)

Get file by md5 hash.

Parameters
<type>$name

Definition at line 59 of file class.ilRestFileStorage.php.

References $GLOBALS, Slim\getInstance(), and ilFileSystemStorage\getPath().

{
//$return = new stdClass();
$GLOBALS['ilLog']->write(__METHOD__.' '.$this->getPath().'/'.$name);
if(file_exists($this->getPath().'/'.$name))
{
$GLOBALS['ilLog']->write(__METHOD__.' file exists');
$return = file_get_contents($this->getPath().'/'.$name);
}
// Responce header
Slim::getInstance()->response()->header('Content-Type', 'application/json');
Slim::getInstance()->response()->body($return);
}

+ Here is the call graph for this function:

ilRestFileStorage::getPathPostfix ( )
protected

Get path prefix.

Reimplemented from ilFileSystemStorage.

Definition at line 41 of file class.ilRestFileStorage.php.

{
return 'files';
}
ilRestFileStorage::getPathPrefix ( )
protected

Get path prefix.

Reimplemented from ilFileSystemStorage.

Definition at line 33 of file class.ilRestFileStorage.php.

{
return 'ilRestFileStorage';
}
ilRestFileStorage::getStoredFilePath (   $tmpname)

Definition at line 105 of file class.ilRestFileStorage.php.

References ilFileSystemStorage\getPath().

{
return $this->getPath().'/'.$tmpname;
}

+ Here is the call graph for this function:

ilRestFileStorage::init ( )
protected

init and create directory

Reimplemented from ilFileSystemStorage.

Definition at line 49 of file class.ilRestFileStorage.php.

References ilFileSystemStorage\create().

{
$this->create();
}

+ Here is the call graph for this function:

ilRestFileStorage::storeFileForRest (   $content)

Definition at line 96 of file class.ilRestFileStorage.php.

References ilFileSystemStorage\$path, ilFileSystemStorage\getPath(), ilUtil\ilTempnam(), and ilFileSystemStorage\writeToFile().

{
$tmpname = ilUtil::ilTempnam();
$path = $this->getPath().'/'.basename($tmpname);
$this->writeToFile($content, $path);
return basename($tmpname);
}

+ Here is the call graph for this function:

Field Documentation

const ilRestFileStorage::AVAILABILITY_IN_DAYS = 1

Definition at line 15 of file class.ilRestFileStorage.php.


The documentation for this class was generated from the following file: