tpyo / amazon-s3-php-class

A standalone Amazon S3 (REST) client for PHP 5/CURL
1.03k stars 503 forks source link

Disable adding bucket name as subdomain to endpoint #153

Closed 4n70w4 closed 5 years ago

4n70w4 commented 5 years ago

Hi! I use custom storage server via s3 api specification.

$s3 = new S3('123', '456', true, 'storage.something');

S3::getObject('bucket-test', 'cert_20000.pdf');

PHP Warning: S3::getObject(bucket-test, cert_20000.pdf): [51] SSL: no alternative certificate subject name matches target host name 'bucket-test.something' in /app/vendor/tpyo/amazon-s3-php-class/S3.php on line 373

Problem: my server do not support subdomains for buckets.

How can I disable it or fix it differently?

4n70w4 commented 5 years ago

Okay. Solution: need empty bucket argument, but add bucket name to filename.

S3::putObject(S3::inputFile('cert_20000.pdf', false), '', 'bucket-test/cert_20000.pdf', S3::ACL_PUBLIC_READ);

$d = S3::getObject('', 'bucket-test/cert_20000.pdf');

tpyo commented 5 years ago

Glad you figured something out. FYI you can also disable SSL if that is acceptable to you. That is the required approach for Amazon S3 bucket names that are not valid subdomains.