0
votes

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

1
This appears to be a problem with the temporary directory used by PHP on your local machine (i.e., not an S3 problem). Check what temp directory PHP thinks it is using; make sure it exists and you have write access to it. A quick google suggests sys_get_temp_dir() will give you the current temp directory location.rmlockerd
I'm using the following temp path : upload_tmp_dir="/Applications/XAMPP/xamppfiles/temp/" I also have set up privileges with all permissions but I still got the issue...Romain
When I'm displaying the temp path, i'm getting the following : "/var/folders/1x/2rgn960n1cv19zz0k22cgx180000gn/T" I'm trying to modify the permission but everything is looked in macRomain

1 Answers

0
votes

The problem was my local configuration on Wamp. I have uploaded my code on an UAT server everything was working like a charm. Thanks to @rmlockerd for the hint ;)