Bitte zuerst echte Access Key und Secret Key eintragen.";
} else {
require __DIR__ . '/vendor/autoload.php';
$s3 = new Aws\S3\S3Client([
'region' => $region,
'version' => 'latest',
'endpoint' => "https://s3.{$region}.wasabisys.com",
'credentials' => [
'key' => $accessKey,
'secret' => $secretKey,
],
'signature_version' => 'v4',
'http' => ['verify' => true],
]);
echo "
Starte Durchlauf …";
$totalCount = 0;
$totalUpdated = 0;
foreach ($folders as $prefix => $description) {
echo "
Ordner: " . htmlspecialchars($prefix) . " (" . htmlspecialchars($description) . ")
";
try {
$paginator = $s3->getPaginator('ListObjectsV2', [
'Bucket' => $bucket,
'Prefix' => $prefix,
]);
$count = 0;
$updated = 0;
foreach ($paginator as $result) {
if (empty($result['Contents'])) {
continue;
}
foreach ($result['Contents'] as $object) {
$key = $object['Key'];
$count++;
$totalCount++;
if (substr($key, -1) === '/') {
continue;
}
try {
$s3->putObjectAcl([
'Bucket' => $bucket,
'Key' => $key,
'ACL' => 'public-read',
]);
echo "✅ " . htmlspecialchars($key) . "
";
$updated++;
$totalUpdated++;
} catch (Aws\Exception\AwsException $e) {
echo "❌ " . htmlspecialchars($key) . ": " . htmlspecialchars($e->getAwsErrorMessage()) . "
";
}
}
}
echo "
In diesem Ordner: {$count} Objekte, {$updated} auf public-read gesetzt.
";
} catch (Aws\Exception\AwsException $e) {
echo "
Fehler bei " . htmlspecialchars($prefix) . ": " . htmlspecialchars($e->getMessage()) . "
";
}
}
echo "
Fertig.
";
echo "
Gesamt gefunden: {$totalCount}
";
echo "Auf public-read gesetzt: {$totalUpdated}
";
echo "
Öffentliche URLs:
";
foreach ($folders as $prefix => $description) {
echo "- " . htmlspecialchars($description) . ":
https://s3." . htmlspecialchars($region) . ".wasabisys.com/" . htmlspecialchars($bucket) . "/" . htmlspecialchars($prefix) . "datei ";
}
echo "
";
}
?>