- Модуль: mobile
- Путь к файлу: ~/bitrix/modules/mobile/lib/rest/disk.php
- Класс: BitrixMobileRestDisk
- Вызов: Disk::getAttachmentsData
static function getAttachmentsData($params)
{
$result = [];
$attachmentsIds = (is_array($params['attachmentsIds']) ? $params['attachmentsIds'] : []);
$driver = Driver::getInstance();
$urlManager = $driver->getUrlManager();
foreach ($attachmentsIds as $id)
{
$attachedObject = AttachedObject::loadById($id, ['OBJECT']);
if(!$attachedObject || $file = !$attachedObject->getFile())
{
continue;
}
$file = $attachedObject->getFile();
$extension = $file->getExtension();
$result[] = [
'ID' => $id,
'OBJECT_ID' => $file->getId(),
'NAME' => $file->getName(),
'SIZE' => CFile::formatSize($file->getSize()),
'EXTENSION' => $extension,
'TYPE' => TypeFile::getByExtension($extension),
'URL' => $urlManager::getUrlUfController('show', ['attachedId' => $id]),
'IS_IMAGE' => TypeFile::isImage($file),
'CREATE_TIME' => CRestUtil::ConvertDateTime($file->getCreateTime()),
'UPDATE_TIME' => CRestUtil::ConvertDateTime($file->getUpdateTime()),
];
}
return $result;
}