return $fname;
}
+ /**
+ * @throws \Exception
+ */
protected function _zipAssets($id)
{
/** @var Asset $asset */
$asset = Asset::find($id);
$collection = $asset->getMediaInField($asset->getAttributeValue('file_upload'));
$tmp = Files::tmpdir();
- $zip = Files::tempnam() . '.zip';
+ $zip = Files::tempnam($this->wdir) . '.zip';
foreach ($collection as $item) {
$path = $item->getPath();
- $spl = new \SplFileInfo($path);
/** @var $item Media */
- copy($path, $tmp . $spl->getFilename());
+ $dest = $tmp . '/' . Files::getFilename($path);
+ copy($path, $dest);
}
Zip::archive($tmp, $zip);
+ if (!file_exists($zip)) {
+ throw new \Exception('Error while compressing assets of ' . $id . ' (' . $tmp . ')');
+ }
Files::rmdir($tmp);
- return $zip;
+ return Files::getFilename($zip);
}