This is my code:
$client = new S3Client([
'version' => 'latest',
'region' => $region,
'credentials' => ['key' => $key, 'secret' => $secret]
]);
$client->registerStreamWrapper();
$filename = md5(gethostname()) .'_'. basename($file);
$bucketStream = fopen("s3://{$bucket}/{$filename}", 'w+');
If I list my buckets, I get a list of them, so it is not a connection problem. My issue that I can't upload any files to S3. and this: $bucketStream
is false
.
You can upload larger files by streaming data using fopen() and a "w", "x", or "a" stream access mode. The Amazon S3 stream wrapper does not support simultaneous read and write streams (eg "r+", "w+", etc). This is because the HTTP protocol does not allow simultaneous reading and writing.
try to change the w+
to w
Reference : http://docs.aws.amazon.com/aws-sdk-php/v2/guide/feature-s3-stream-wrapper.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.