Skip to content

Commit

Permalink
ESD-15 - Fix compress file
Browse files Browse the repository at this point in the history
  • Loading branch information
hungmac-sw committed Jun 23, 2022
1 parent 84ec5a0 commit a26c35d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
1 change: 0 additions & 1 deletion src/Resources/app/storefront/src/scss/base.scss
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
@import 'page/account/esd-downloads';
@import "../../node_modules/plyr/src/sass/plyr";
2 changes: 1 addition & 1 deletion src/Resources/public/administration/js/sas-esd.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/Resources/public/administration/js/sas-esd.js.map

Large diffs are not rendered by default.

16 changes: 9 additions & 7 deletions src/Service/EsdService.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,15 @@ public function compressFiles($productId): void
$tempFiles = [];
/** @var EsdMediaEntity $media */
foreach ($medias as $media) {
$newfile = $this->getTempFolder() . $media->getMedia()->getFileName() . '.' . $media->getMedia()->getFileExtension();
$filename = $media->getMedia()->getFileName() . '.' . $media->getMedia()->getFileExtension();
$newfile = $this->getTempFolder() . '/' . $filename;

$mediaBlob = $this->loadMediaFile($media->getMedia());
file_put_contents($newfile, $mediaBlob);

$tempFiles[] = $newfile;
$zip->addFile($newfile);

$zip->addFile($newfile, $filename);
}

$zip->close();
Expand Down Expand Up @@ -311,11 +313,11 @@ public function getFileSize(string $productId): string
$power = $size > 0 ? floor(log($size, 1024)) : 0;

return number_format(
$size / pow(1024, $power),
2,
'.',
','
) . ' ' . $units[$power];
$size / pow(1024, $power),
2,
'.',
','
) . ' ' . $units[$power];
}

public function getSystemConfig(string $name): bool
Expand Down

0 comments on commit a26c35d

Please sign in to comment.