I'm using the php S3 SDK to download files. The download is working for some files but not all them... Here is the following error for a jpeg image :
Warning: curl_multi_exec(): Unable to create temporary file, Check permissions in temporary files directory. in /Applications/XAMPP/xamppfiles/htdocs/XXXX/wp-content/themes/XXXX/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php on line 128
Warning: curl_multi_exec(): Unable to create temporary file, Check permissions in temporary files directory. in /Applications/XAMPP/xamppfiles/htdocs/XXXX/wp-content/themes/XXXX/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php on line 128
Warning: curl_multi_exec(): Unable to create temporary file, Check permissions in temporary files directory. in /Applications/XAMPP/xamppfiles/htdocs/XXXX/wp-content/themes/XXXX/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php on line 128 Error executing "GetObject" on "https://XXXX.s3.eu-west-3.amazonaws.com/folderName/filename?response-content-type=text%2Fplain&response-content-language=en-US&response-content-disposition=attachment%3B%20filename%3Dtesting.txt&response-cache-control=No-cache&response-expires=2020-07-02T16%3A03%3A23Z"; AWS HTTP error: cURL error 23: Failed writing body (7744 != 16360) (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) Unable to parse error information from response - Error parsing XML: String could not be parsed as XML
<?php
// AWS Info + Connection
$bucketName = 'XXXXX';
$IAM_KEY = 'XXXXX';
$IAM_SECRET = 'XXXXX';
$region = 'eu-west-3';
require '../../vendor/autoload.php';
use Aws\S3\S3Client;
use Aws\S3\Exception\S3Exception;
$rdvID=$_GET['folerName'];
$nameFile=$_GET['nameFile'];
$keyPath=$rdvID."/".$nameFile;
// Get file
$s3 = S3Client::factory(
array(
'credentials' => array(
'key' => $IAM_KEY,
'secret' => $IAM_SECRET
),
'version' => 'latest',
'region' => $region
)
);
try {
$result = $s3->getObject(array(
'Bucket' => $bucketName,
'Key' => $keyPath
));
// Display the object in the browser.
header("Content-Type: {$result['ContentType']}");
echo $result['Body'];
} catch (S3Exception $e) {
echo $e->getMessage() . PHP_EOL;
}
On my s3, I'm able to download all files properly.
Thanks in advance
sys_get_temp_dir()
will give you the current temp directory location. – rmlockerd