本文整理汇总了PHP中Topxia\Common\FileToolkit::getFileTypeByMimeType方法的典型用法代码示例。如果您正苦于以下问题:PHP FileToolkit::getFileTypeByMimeType方法的具体用法?PHP FileToolkit::getFileTypeByMimeType怎么用?PHP FileToolkit::getFileTypeByMimeType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Topxia\Common\FileToolkit
的用法示例。
在下文中一共展示了FileToolkit::getFileTypeByMimeType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addFile
public function addFile($targetType, $targetId, array $fileInfo = array(), UploadedFile $originalFile = null)
{
if (!ArrayToolkit::requireds($fileInfo, array('filename', 'key', 'size'))) {
throw $this->createServiceException('参数缺失,添加用户文件失败!');
}
$uploadFile = array();
$uploadFile['targetId'] = $targetId;
$uploadFile['targetType'] = $targetType;
$uploadFile['hashId'] = $fileInfo['key'];
$uploadFile['filename'] = $fileInfo['filename'];
$uploadFile['ext'] = pathinfo($uploadFile['filename'], PATHINFO_EXTENSION);
$uploadFile['size'] = (int) $fileInfo['size'];
$uploadFile['etag'] = empty($fileInfo['etag']) ? '' : $fileInfo['etag'];
$uploadFile['length'] = empty($fileInfo['length']) ? 0 : intval($fileInfo['length']);
$uploadFile['metas'] = $this->encodeMetas(empty($fileInfo['metas']) ? array() : $fileInfo['metas']);
$uploadFile['metas2'] = $this->encodeMetas(empty($fileInfo['metas2']) ? array() : $fileInfo['metas2']);
if (empty($fileInfo['convertHash'])) {
$uploadFile['convertHash'] = "ch-{$uploadFile['hashId']}";
$uploadFile['convertStatus'] = 'none';
$uploadFile['convertParams'] = '';
} else {
$uploadFile['convertHash'] = "{$fileInfo['convertHash']}";
$uploadFile['convertStatus'] = 'waiting';
$uploadFile['convertParams'] = $fileInfo['convertParams'];
}
$uploadFile['type'] = FileToolkit::getFileTypeByMimeType($fileInfo['mimeType']);
$uploadFile['canDownload'] = empty($uploadFile['canDownload']) ? 0 : 1;
$uploadFile['storage'] = 'cloud';
$uploadFile['createdUserId'] = $this->getCurrentUser()->id;
$uploadFile['updatedUserId'] = $uploadFile['createdUserId'];
$uploadFile['updatedTime'] = $uploadFile['createdTime'] = time();
return $uploadFile;
}