From 095b3884cc1b7936d3d8d094b2e8b3f9921bac00 Mon Sep 17 00:00:00 2001 From: Alex Rothberg Date: Tue, 3 Jun 2025 01:28:58 -0400 Subject: [PATCH] use Filesystem copy. --- src/DataSource/Loader/HttpLoader.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/DataSource/Loader/HttpLoader.php b/src/DataSource/Loader/HttpLoader.php index 6bc17545..f371f240 100644 --- a/src/DataSource/Loader/HttpLoader.php +++ b/src/DataSource/Loader/HttpLoader.php @@ -12,6 +12,7 @@ namespace Pimcore\Bundle\DataImporterBundle\DataSource\Loader; +use Exception; use Pimcore\Bundle\DataImporterBundle\Exception\InvalidConfigurationException; use Symfony\Component\Filesystem\Filesystem; @@ -40,15 +41,23 @@ public function __construct( public function loadData(): string { $folder = PIMCORE_PRIVATE_VAR . '/tmp/datahub/dataimporter/http-loader/'; - $this->filesystem->mkdir($folder, 0775); $this->importFilePath = $folder . uniqid('http-import-'); $fullUrl = $this->schema . $this->url; - if (copy($fullUrl, $this->importFilePath)) { + try { + $this->filesystem->copy($fullUrl, $this->importFilePath, true); return $this->importFilePath; - } else { - throw new InvalidConfigurationException(sprintf('Could not copy from remote location `%s` to local tmp file `%s`', $fullUrl, $this->importFilePath)); + } catch (Exception $ex){ + throw new InvalidConfigurationException( + sprintf( + 'Could not copy from remote location `%s` to local tmp file `%s`', + $fullUrl, + $this->importFilePath + ), + 0, + $ex + ); } }