41 lines
1.0 KiB
PHP
41 lines
1.0 KiB
PHP
<?php
|
|
require 'vendor/autoload.php';
|
|
|
|
use Aws\S3\S3Client;
|
|
use Aws\S3\Exception\S3Exception;
|
|
|
|
// Konfigurasi MinIO
|
|
$accessKey = "admin"; // MINIO_ROOT_USER atau user lain
|
|
$secretKey = "@P4ssw0rd"; // MINIO_ROOT_PASSWORD
|
|
$bucketName = "rjn";
|
|
$minioEndpoint = "http://172.17.17.66:9000"; // ganti sesuai server Anda
|
|
$region = "us-east-1"; // default region
|
|
|
|
// Buat client S3
|
|
$s3 = new S3Client([
|
|
'version' => 'latest',
|
|
'region' => $region,
|
|
'endpoint' => $minioEndpoint,
|
|
'use_path_style_endpoint' => true,
|
|
'credentials' => [
|
|
'key' => $accessKey,
|
|
'secret' => $secretKey,
|
|
],
|
|
]);
|
|
|
|
// Nama file di bucket yang akan dihapus
|
|
$key = 'foto/tes.jpg';
|
|
|
|
try {
|
|
// Hapus objek dari MinIO
|
|
$result = $s3->deleteObject([
|
|
'Bucket' => $bucketName,
|
|
'Key' => $key,
|
|
]);
|
|
|
|
echo "File '{$key}' telah berhasil dihapus dari bucket '{$bucketName}'.";
|
|
|
|
} catch (S3Exception $e) {
|
|
echo "Gagal menghapus file: " . $e->getMessage() . PHP_EOL;
|
|
}
|