Skip to content

Commit d9818d8

Browse files
committed
B2B-2067:Gallery Image is not saving the remote storage file on to local
- Added static fixes
1 parent 415a444 commit d9818d8

File tree

1 file changed

+21
-18
lines changed

1 file changed

+21
-18
lines changed

app/code/Magento/RemoteStorage/Plugin/GalleryImageCopy.php

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -62,38 +62,41 @@ public function __construct(
6262
* @param callable $proceed
6363
* @return string
6464
* @throws FileSystemException
65+
* @throws \Magento\Framework\Exception\RuntimeException
6566
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
6667
*/
6768
public function aroundGetImageWidth(Gallery $subject, callable $proceed): string
6869
{
69-
if($this->config->IsEnabled()){
70-
$file = $subject->getCurrentImage()->getPath();
71-
return $this->copyFileToTmp($file);
72-
}
70+
return $this->copyFileToTmp($subject,$proceed);
7371
}
7472

7573
/**
7674
* Move files from storage to tmp folder
7775
*
78-
* @param string $filePath
76+
* @param Gallery $subject
77+
* @param callable $proceed
7978
* @return string
8079
* @throws FileSystemException
80+
* @throws \Magento\Framework\Exception\RuntimeException
8181
*/
82-
private function copyFileToTmp(string $filePath): string
82+
private function copyFileToTmp(Gallery $subject, callable $proceed): string
8383
{
84-
if ($this->fileExistsInTmp($filePath)) {
85-
return $this->tmpFiles[$filePath];
86-
}
87-
$absolutePath = $this->remoteDirectoryWrite->getAbsolutePath($filePath);
88-
if ($this->remoteDirectoryWrite->isFile($absolutePath)) {
89-
$this->tmpDirectoryWrite->create();
90-
$tmpPath = $this->storeTmpName($filePath);
91-
$content = $this->remoteDirectoryWrite->getDriver()->fileGetContents($filePath);
92-
$filePath = $this->tmpDirectoryWrite->getDriver()->filePutContents($tmpPath, $content)
93-
? $tmpPath
94-
: $filePath;
84+
if ($this->config->IsEnabled()) {
85+
$filePath = $subject->getCurrentImage()->getPath();
86+
if ($this->fileExistsInTmp($filePath)) {
87+
return $this->tmpFiles[$filePath];
88+
}
89+
$absolutePath = $this->remoteDirectoryWrite->getAbsolutePath($filePath);
90+
if ($this->remoteDirectoryWrite->isFile($absolutePath)) {
91+
$this->tmpDirectoryWrite->create();
92+
$tmpPath = $this->storeTmpName($filePath);
93+
$content = $this->remoteDirectoryWrite->getDriver()->fileGetContents($filePath);
94+
$filePath = $this->tmpDirectoryWrite->getDriver()->filePutContents($tmpPath, $content)
95+
? $tmpPath
96+
: $filePath;
97+
}
98+
return $filePath;
9599
}
96-
return $filePath;
97100
}
98101

99102
/**

0 commit comments

Comments
 (0)