34 if (!$this->isAvailable())
36 return $result->addError(
new Error(
'Module disk not available'));
39 $storage = Driver::getInstance()->getStorageByUserId($this->userId);
42 return $result->addError(
new Error(
'Storage not found'));
45 $folder =
$storage->getFolderForUploadedFiles();
48 return $result->addError(
new Error(
'Upload folder not found'));
51 if (!$folder->canAdd(
$storage->getSecurityContext($this->userId)))
56 $fileArray = \CFile::GetFileArray($fileId);
58 $addedFile = $folder->addFile(
60 'NAME' => Text::correctFilename($fileArray[
'ORIGINAL_NAME']),
62 'CONTENT_PROVIDER' =>
null,
63 'SIZE' => $fileArray[
'FILE_SIZE'],
64 'CREATED_BY' => $this->userId,
65 'UPDATE_TIME' =>
null,
73 return $result->addError(
new Error(
'Error while uploading file'));
78 'ATTACHMENT_ID' => self::NEW_FILE_PREFIX . $addedFile->getId(),