Skip to content

Commit

Permalink
TASK: Import asset via guzzlehttp instead of fopen to apply assetSour…
Browse files Browse the repository at this point in the history
…ceOptions there aswell
  • Loading branch information
mficzel committed Jun 9, 2020
1 parent 5ea5798 commit 9ae2c6f
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Classes/AssetSource/PixxioAssetProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

use Behat\Transliterator\Transliterator;
use Exception;
use Flownative\Pixxio\Exception\ConnectionException;
use GuzzleHttp\Client;
use Neos\Flow\Http\Uri;
use Neos\Media\Domain\Model\AssetSource\AssetProxy\AssetProxyInterface;
use Neos\Media\Domain\Model\AssetSource\AssetProxy\HasRemoteOriginalInterface;
Expand Down Expand Up @@ -287,7 +289,17 @@ public function getPreviewUri(): ?UriInterface
*/
public function getImportStream()
{
return fopen($this->originalUri, 'rb');
$client = new Client($this->assetSource->getAssetSourceOptions()['apiClientOptions'] ?? []);
try {
$response = $client->request('GET', $this->originalUri);
if ($response->getStatusCode() === 200) {
return $response->getBody()->detach();
} else {
return false;
}
} catch (GuzzleException $e) {
throw new ConnectionException('Retrieving file failed: ' . $e->getMessage(), 1542808207);
}
}

/**
Expand Down

0 comments on commit 9ae2c6f

Please sign in to comment.