Code: Select all
// $filecontent is data from Flysystem
$fileContent = $this->documentStorage->read('remote filename.pdf');
file_put_contents(__DIR__.'/test.pdf', $fileContent);
$fileHandle = fopen(__DIR__.'/test.pdf', 'rb');
$params = [
'body' => [
'bestand' => $fileHandle
],
];
$response = $this->createClient()->request('POST', $url, $params);
Code: Select all
$stream = fopen('php://temp', 'rb+');
fwrite($stream, $fileContent);
rewind($stream);
$params = [
'body' => [
'bestand' => $stream
],
];
$response = $this->createClient()->request('POST', $url, $params);
< /code>
versucht manuell ein mehrteiliges Formular zu erstellen, funktioniert auch nicht: < /p>
$dp = new DataPart($fileContent);
$formData = new FormDataPart(['bestand' => $dp]);
$preparedHeaders = $formData->getPreparedHeaders();
$params = [
'body' => $formData->bodyToString(),
'headers' => [
trim($preparedHeaders->toString())
],
];
$response = $this->createClient()->request('POST', $url, $params);