vendredi 9 mars 2018

Aws-Sdk-Php version 2, Custom ending point is made as virtual Host instead of path style

I am trying to set a custom endpoint to test some features locally

$aws = $aws = \AWS::factory(array(
            'endpoint' => "localhost:4572"
        ));
        $this->s3 = $aws->get('s3');

But it is giving this error at the time to put images in the server with this wrong url:

//mybucket.localhost:4572/img.jpg

When it should be like this:

http://localhost:4572/mybucket/img.jpg

public function putFileObjectsTo(array $array)
    {
        $targetBucket = self::$BUCKET;
        $batch = array();
        foreach ($array as $value) {
            $path = $value['path'];
            $targetKeyname = $value['targetKeyname'];
            $batch[] = \Guzzle\Service\Client('putObject', array(
                'Bucket' => $targetBucket,
                'Key' => $targetKeyname,
                'SourceFile' => $path,
                'ACL' => 'public-read',
                'CacheControl' => 'max-age=15552000',
                'ContentType' => 'image/jpeg',
                'MetadataDirective' => 'REPLACE'
            ));
        }
        $this->s3->execute($batch);
    }



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire