Downloadable Products File Helper
@api
- Since
- 100.0.2
Definition at line 16 of file File.php.
◆ __construct()
- Parameters
-
\Magento\Framework\App\Helper\Context | $context | |
\Magento\MediaStorage\Helper\File\Storage\Database | $coreFileStorageDatabase | |
\Magento\Framework\Filesystem | $filesystem | |
array | $mimeTypes | |
Definition at line 45 of file File.php.
51 $this->_coreFileStorageDatabase = $coreFileStorageDatabase;
54 parent::__construct($context);
55 if (!empty($mimeTypes)) {
56 foreach ($mimeTypes as $key =>
$value) {
57 self::$_mimeTypes[$key] =
$value;
◆ _getFileTypeByExt()
_getFileTypeByExt |
( |
|
$ext | ) |
|
|
protected |
- Parameters
-
- Returns
- string
Definition at line 205 of file File.php.
208 if (isset(self::$_mimeTypes[
$type])) {
209 return self::$_mimeTypes[
$type];
211 return 'application/octet-stream';
◆ _moveFileFromTmp()
_moveFileFromTmp |
( |
|
$baseTmpPath, |
|
|
|
$basePath, |
|
|
|
$file |
|
) |
| |
|
protected |
Move file from tmp path to base path
- Parameters
-
string | $baseTmpPath | |
string | $basePath | |
string | $file | |
- Returns
- string
Definition at line 128 of file File.php.
130 if (strrpos($file,
'.tmp') == strlen($file) - 4) {
131 $file = substr($file, 0, strlen($file) - 4);
140 $this->_coreFileStorageDatabase->copyFile(
145 $this->_mediaDirectory->renameFile(
150 return str_replace(
'\\',
'/', $destFile);
static getNewFileName($destinationFile)
getFilePath($path, $file)
◆ ensureFileInFilesystem()
ensureFileInFilesystem |
( |
|
$file | ) |
|
Check if file exist in filesystem and try to re-create it from database record if negative.
- Parameters
-
- Returns
- bool|int
Definition at line 110 of file File.php.
113 if (!$this->_mediaDirectory->isFile($file)) {
114 $result = $this->_coreFileStorageDatabase->saveFileToFilesystem($file);
◆ getAllFileTypes()
- Returns
- array
Definition at line 217 of file File.php.
219 return array_values(self::getAllMineTypes());
◆ getAllMineTypes()
◆ getFileFromPathFile()
getFileFromPathFile |
( |
|
$pathFile | ) |
|
Return file name form file path
- Parameters
-
- Returns
- string
Definition at line 174 of file File.php.
176 $file = substr($pathFile, strrpos($pathFile,
'/') + 1);
◆ getFilePath()
getFilePath |
( |
|
$path, |
|
|
|
$file |
|
) |
| |
Return full path to file
- Parameters
-
- Returns
- string
Definition at line 160 of file File.php.
163 $file = ltrim($file,
'/');
165 return $path .
'/' . $file;
◆ getFileSize()
Get filesize in bytes.
- Parameters
-
- Returns
- int
Definition at line 186 of file File.php.
188 return $this->_mediaDirectory->stat($file)[
'size'];
◆ getFileType()
- Parameters
-
- Returns
- string
Definition at line 195 of file File.php.
197 $ext = substr($filePath, strrpos($filePath,
'.') + 1);
◆ moveFileFromTmp()
moveFileFromTmp |
( |
|
$baseTmpPath, |
|
|
|
$basePath, |
|
|
|
$file |
|
) |
| |
Checking file for moving and move it
- Parameters
-
string | $baseTmpPath | |
string | $basePath | |
string | $file | |
- Returns
- string
- Exceptions
-
Definition at line 87 of file File.php.
89 if (isset($file[0])) {
91 if ($file[0][
'status'] ===
'new') {
94 }
catch (\Exception $e) {
95 throw new \Magento\Framework\Exception\LocalizedException(
96 __(
'Something went wrong while saving the file(s).')
_moveFileFromTmp($baseTmpPath, $basePath, $file)
◆ uploadFromTmp()
Upload file from temporary folder.
- Parameters
-
string | $tmpPath | |
\Magento\MediaStorage\Model\File\Uploader | $uploader | |
- Returns
- array
Definition at line 68 of file File.php.
70 $uploader->setAllowRenameFiles(
true);
71 $uploader->setFilesDispersion(
true);
72 $absoluteTmpPath = $this->_mediaDirectory->getAbsolutePath($tmpPath);
73 $result = $uploader->save($absoluteTmpPath);
◆ $_coreFileStorageDatabase
$_coreFileStorageDatabase = null |
|
protected |
◆ $_filesystem
◆ $_mediaDirectory
◆ $_mimeTypes
The documentation for this class was generated from the following file:
- vendor/magento/module-downloadable/Helper/File.php