Pisah server penyimpanan dan update payment gateway
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?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,
|
||||
],
|
||||
]);
|
||||
|
||||
// Upload file
|
||||
try {
|
||||
$result = $s3->putObject([
|
||||
'Bucket' => $bucketName,
|
||||
'Key' => 'foto/tes.jpg', // nama file di bucket
|
||||
'SourceFile' => 'tes.jpg', // file lokal
|
||||
]);
|
||||
echo "Upload sukses: " . $result['ObjectURL'] . PHP_EOL;
|
||||
} catch (S3Exception $e) {
|
||||
echo "Upload gagal: " . $e->getMessage() . PHP_EOL;
|
||||
}
|
||||
Reference in New Issue
Block a user