21 use Magento\MediaStorage\Model\File\UploaderFactory;
58 UploaderFactory $uploaderFactory,
91 if (!isset(
$value[
'file'])) {
93 __(
'%1 does not contain field \'file\'', $this->
getData(
'field_config/field'))
96 if (isset(
$value[
'exists'])) {
97 $this->setValue(
$value[
'file']);
101 $filename = basename(
$value[
'file']);
102 $result = $this->_mediaDirectory->copyFile(
111 $this->setValue($filename);
128 if ($this->_mediaDirectory->isExist(
$fileName)) {
129 $stat = $this->_mediaDirectory->stat(
$fileName);
135 'size' => is_array($stat) ? $stat[
'size'] : 0,
136 'name' => basename(
$value),
165 return $this->_mediaDirectory->getRelativePath($uploadDir);
173 return $this->
getData(
'value') ?: [];
184 $fieldConfig = $this->getFieldConfig();
186 $urlType = [
'_type' => UrlInterface::URL_TYPE_MEDIA];
187 if (isset($fieldConfig[
'base_url'])) {
188 $baseUrl = $fieldConfig[
'base_url'];
189 $urlType = [
'_type' => empty($baseUrl[
'type']) ?
'link' : (string)$baseUrl[
'type']];
190 $baseUrl = $baseUrl[
'value'] .
'/';
192 return $this->urlBuilder->getBaseUrl($urlType) . $baseUrl .
$fileName;
203 return 'tmp/' . FileProcessor::FILE_DIR .
'/' . $filename;
214 $absoluteFilePath = $this->_mediaDirectory->getAbsolutePath(
$fileName);
216 $result = $this->getMime()->getMimeType($absoluteFilePath);
227 private function getMime()
229 if ($this->mime ===
null) {
getStoreMediaUrl($fileName)
getUploadDirPath($uploadDir)
getData($key='', $index=null)
getTmpMediaPath($filename)
__construct(Context $context, Registry $registry, ScopeConfigInterface $config, TypeListInterface $cacheTypeList, UploaderFactory $uploaderFactory, RequestDataInterface $requestData, Filesystem $filesystem, UrlInterface $urlBuilder, AbstractResource $resource=null, AbstractDb $resourceCollection=null, array $data=[])