19 declare(strict_types=1);
44 $this->
logger = $DIC->logger()->wsrv();
54 if (!$this->
settings->get(
'soap_user_administration',
'0')) {
55 $this->
logger->warning(
'Webservices disabled in administration.');
58 ->withHeader(
'Content-Type',
'text/html')
59 ->withStatus(\Slim\Http\StatusCode::HTTP_FORBIDDEN)
60 ->write(
'Webservice not enabled.');
67 return 'ilRestFileStorage';
78 protected function init(): bool
88 if ($failure instanceof \Slim\Http\Response) {
92 $file_id = $request->getParam(
'name');
94 $this->
logger->debug(
'Original file name: ' . $file_id);
96 $real_path = realpath($this->
getPath() .
'/' . $file_id);
98 $this->
logger->warning(
'No realpath found for ' . $this->
getPath() .
'/' . $file_id);
101 $file_name = basename($real_path);
102 $this->
logger->debug(
'Translated name: ' . $this->
getPath() .
'/' . $file_name);
105 is_file($this->
getPath() .
'/' . $file_name) &&
106 file_exists($this->
getPath() .
'/' . $file_name)
108 $this->
logger->info(
'Delivering file: ' . $this->
getPath() .
'/' . $file_name);
109 $return = file_get_contents($this->
getPath() .
'/' . $file_name);
111 $this->
logger->dump($return);
114 ->withStatus(\Slim\Http\StatusCode::HTTP_OK)
115 ->withHeader(
'Content-Type',
'application/json')
130 ->withHeader(
'Content-Type',
'text/html')
131 ->withStatus(\Slim\Http\StatusCode::HTTP_NOT_FOUND)
132 ->write(
'File not found');
142 if ($failure instanceof \Slim\Http\Response) {
146 $request_body = $request->getParam(
'content');
152 $return = basename($tmpname);
155 ->withHeader(
'ContentType',
'application/json')
165 return basename($tmpname);
170 return $this->
getPath() .
'/' . $tmpname;
178 $max_age = time() - self::AVAILABILITY_IN_DAYS * 24 * 60 * 60;
180 foreach ($ite as $file) {
181 if ($file->getCTime() <= $max_age) {
183 unlink($file->getPathname());
185 $this->
logger->warning($e->getMessage());
193 if (!$fp = fopen($a_absolute_path,
'wb+')) {
196 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.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
__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)