Skip to content

Commit

Permalink
Merge branch '2.4.7-beta1-develop' into application-server-part3
Browse files Browse the repository at this point in the history
  • Loading branch information
andimov authored Jun 5, 2023
2 parents 9c1a6f4 + a656f4e commit d7512e3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace Magento\Catalog\Model\Product\Gallery;

use Magento\AwsS3\Driver\AwsS3;
use Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface;
use Magento\Catalog\Api\Data\ProductInterfaceFactory;
use Magento\Catalog\Api\ProductRepositoryInterface;
Expand Down Expand Up @@ -287,10 +288,18 @@ private function getImageContent($product, $entry): ImageContentInterface
$mediaDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::MEDIA);
$path = $mediaDirectory->getAbsolutePath($product->getMediaConfig()->getMediaPath($entry->getFile()));
$fileName = $this->file->getPathInfo($path)['basename'];
$imageFileContent = $mediaDirectory->getDriver()->fileGetContents($path);
$fileDriver = $mediaDirectory->getDriver();
$imageFileContent = $fileDriver->fileGetContents($path);

if ($fileDriver instanceof AwsS3) {
$remoteMediaMimeType = $fileDriver->getMetadata($path);
$mediaMimeType = $remoteMediaMimeType['mimetype'];
} else {
$mediaMimeType = $this->mime->getMimeType($path);
}
return $this->imageContentInterface->create()
->setName($fileName)
->setBase64EncodedData(base64_encode($imageFileContent))
->setType($this->mime->getMimeType($path));
->setType($mediaMimeType);
}
}
3 changes: 2 additions & 1 deletion app/code/Magento/Catalog/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"magento/module-ui": "*",
"magento/module-url-rewrite": "*",
"magento/module-widget": "*",
"magento/module-wishlist": "*"
"magento/module-wishlist": "*",
"magento/module-aws-s3": "*"
},
"suggest": {
"magento/module-cookie": "*",
Expand Down

0 comments on commit d7512e3

Please sign in to comment.