17 import(
'lib.pkp.classes.file.PrivateFileManager');
24 parent::__construct();
34 return parent::getBasePath() .
'/temp/';
43 return $temporaryFileDao->getTemporaryFile($fileId, $userId);
51 $temporaryFile = $this->
getFile($fileId, $userId);
53 parent::deleteByPath($this->
getBasePath() . $temporaryFile->getServerFileName());
56 $temporaryFileDao->deleteTemporaryFileById($fileId, $userId);
66 $temporaryFile = $this->
getFile($fileId, $userId);
67 if (isset($temporaryFile)) {
68 $filePath = $this->
getBasePath() . $temporaryFile->getServerFileName();
69 return parent::downloadByPath($filePath,
null, $inline);
90 $newFileName = basename(tempnam($this->
getBasePath(), $fileExtension));
91 if (!$newFileName)
return false;
95 $temporaryFile = $temporaryFileDao->newDataObject();
97 $temporaryFile->setUserId($userId);
98 $temporaryFile->setServerFileName($newFileName);
99 $exploded = explode(
'.', $_FILES[$fileName][
'name']);
101 $temporaryFile->setFileSize($_FILES[$fileName][
'size']);
102 $temporaryFile->setOriginalFileName($this->
truncateFileName($_FILES[$fileName][
'name'], 127));
105 $temporaryFileDao->insertObject($temporaryFile);
107 return $temporaryFile;
124 if (!$this->
fileExists($this->filesDir,
'dir')) {
129 $newFileName = basename(tempnam($this->filesDir, $fileExtension));
130 if (!$newFileName)
return false;
132 if (copy($submissionFile->getFilePath(), $this->filesDir . $newFileName)) {
134 $temporaryFile = $temporaryFileDao->newDataObject();
136 $temporaryFile->setUserId($userId);
137 $temporaryFile->setServerFileName($newFileName);
138 $temporaryFile->setFileType($submissionFile->getFileType());
139 $temporaryFile->setFileSize($submissionFile->getFileSize());
140 $temporaryFile->setOriginalFileName($submissionFile->getOriginalFileName());
143 $temporaryFileDao->insertObject($temporaryFile);
145 return $temporaryFile;
157 if (time() % 100 == 0) {
159 $expiredFiles = $temporaryFileDao->getExpiredFiles();
160 foreach ($expiredFiles as $expiredFile) {
161 $this->
deleteById($expiredFile->getId(), $expiredFile->getUserId());