3 declare(strict_types=1);
30 $this->
logger = $DIC->logger()->wsrv();
40 if (!$this->
settings->get(
'soap_user_administration',
'0')) {
41 $this->
logger->warning(
'Webservices disabled in administration.');
44 ->withHeader(
'Content-Type',
'text/html')
45 ->withStatus(\Slim\Http\StatusCode::HTTP_FORBIDDEN)
46 ->write(
'Webservice not enabled.');
53 return 'ilRestFileStorage';
64 protected function init(): bool
74 if ($failure instanceof \Slim\Http\Response) {
78 $file_id = $request->getParam(
'name');
80 $this->
logger->debug(
'Original file name: ' . $file_id);
82 $real_path = realpath($this->
getPath() .
'/' . $file_id);
84 $this->
logger->warning(
'No realpath found for ' . $this->
getPath() .
'/' . $file_id);
87 $file_name = basename($real_path);
88 $this->
logger->debug(
'Translated name: ' . $this->
getPath() .
'/' . $file_name);
91 is_file($this->
getPath() .
'/' . $file_name) &&
92 file_exists($this->
getPath() .
'/' . $file_name)
94 $this->
logger->info(
'Delivering file: ' . $this->
getPath() .
'/' . $file_name);
95 $return = file_get_contents($this->
getPath() .
'/' . $file_name);
97 $this->
logger->dump($return);
100 ->withStatus(\Slim\Http\StatusCode::HTTP_OK)
101 ->withHeader(
'Content-Type',
'application/json')
116 ->withHeader(
'Content-Type',
'text/html')
117 ->withStatus(\Slim\Http\StatusCode::HTTP_NOT_FOUND)
118 ->write(
'File not found');
128 if ($failure instanceof \Slim\Http\Response) {
132 $request_body = $request->getParam(
'content');
138 $return = basename($tmpname);
141 ->withHeader(
'ContentType',
'application/json')
151 return basename($tmpname);
156 return $this->
getPath() .
'/' . $tmpname;
164 $max_age = time() - self::AVAILABILITY_IN_DAYS * 24 * 60 * 60;
165 $ite =
new DirectoryIterator($this->
getPath());
166 foreach ($ite as $file) {
167 if ($file->getCTime() <= $max_age) {
169 unlink($file->getPathname());
171 $this->
logger->warning($e->getMessage());
179 if (!$fp = fopen($a_absolute_path,
'wb+')) {
182 if (fwrite($fp, $a_data) ===
false) {
getFile(Request $request, Response $response)
writeToFile($a_data, $a_absolute_path)
checkWebserviceActivation(Request $request, Response $response)
createFile(Request $request, Response $response)
Create new file from post.
responeNotFound(Response $response)
Send 403.
getStoredFilePath(string $tmpname)
init()
init and create directory
deleteDeprecated()
Delete deprecated files.
__construct()
Constructor.
const AVAILABILITY_IN_DAYS
static ilTempnam(?string $a_temp_path=null)
Returns a unique and non existing Path for e temporary file or directory.
__construct(Container $dic, ilPlugin $plugin)
storeFileForRest(string $content)