/** * Load from local file * * @param string $path Absolute path * @param string $basename File name OPTIONAL * * @return boolean */ public function loadFromLocalFile($path, $basename = null) { if (!$this->s3Forbid && $this->getS3()) { $result = false; if (\Includes\Utils\FileManager::isExists($path)) { $data = @getimagesize($path); if (is_array($data)) { $basename = $basename ?: basename($path); $s3Path = $this->generateS3Path($basename); $s3Path = $this->getS3()->generateUniquePath($s3Path); $headers = array('Content-Type' => $data['mime'], 'Content-Disposition' => 'inline; filename="' . $basename . '"'); if ($this->getS3()->copy($path, $s3Path, $headers)) { $this->setStorageType(static::STORAGE_S3); $this->setMime($data['mime']); if ($this->savePath($s3Path)) { $result = true; } } else { \XLite\Logger::getInstance()->log('[Amazon S3] The file \'' . $path . '\' was not copyed to \'' . $s3Path . '\'', LOG_ERR); } } } } else { $result = parent::loadFromLocalFile($path, $basename); } return $result; }