Enterprise Object Storage (S3 Compatible)

Multi-Cloud High Speed Object Storage S3 compatible object storage

HostingRaja offers high-performance nvme based, S3 compatible object storage. Native to Kubernetes, But works with every public cloud, every Kubernetes distribution, the private cloud.

Contact Us – Object Storage
Captcha

True Multi-Cloud & High Speed S3 Compatible Object Storage

True Multi-Cloud & High Speed S3 Compatible object storage

How to setup storage S3 Bucket using PHP

1) Download AWS SDK from https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/getting-started_installation.html
2) You should have php-xml, php-mbstring modules to use above sdk.
3) Create a user and give a readwrite access policy in storage UI.
4) Create Service Accounts for the user with below service policy. The below policy will give the full access to create bucket, putobject in bucket and getobject from bucket.
{
 "Version": "2012-10-17",
 "Statement": [
  {
   "Effect": "Allow",
   "Action": [
"admin:ServerTrace",
"admin:TopLocksInfo",
"admin:BandwidthMonitor",
"admin:ConsoleLog",
"admin:OBDInfo",
"admin:Profiling",
"admin:Prometheus",
"admin:ServerInfo"
   ],
  "Resource": [
"arn:aws:s3:::*"
   ]
  },
  {
   "Effect": "Allow",
   "Action": [
"admin:*"
   ]
  },
  {
   "Effect": "Allow",
   "Action": [
"s3:*"
   ],
   "Resource": [
"arn:aws:s3:::*"
   ]
  }
 ]
}
  5) Once you create, note down the key and secret. 6) Connect your storage server using below. Change your ‘endpoint’, ‘key’, ‘secret’ as you noted.
<?php
// Include the SDK using the Composer autoloader
date_default_timezone_set('America/Los_Angeles');
require 'vendor/autoload.php';
$s3 = new Aws\S3\S3Client([
'version' => 'latest',
'region'  => 'us-east-1',
'endpoint' => 'http://ip_address:9000',
'use_path_style_endpoint' => true,
'credentials' => [
'key'    => 'YOUR-ACCESSKEYID',
'secret' => 'YOUR-SECRETACCESSKEY',
],
]);
?>
  7) You can create a bucket using the method below.
<?php
$bucket_name = 'testbucket';
// This policy sets the bucket to read and write full access
$policyReadOnly = '{
  "Version": "2012-10-17",
  "Statement": [
{
  "Action": [
"s3:*"
  ],
  "Effect": "Allow",
  "Principal": {
"AWS": [
  "*"
]
  },
  "Resource": [
"arn:aws:s3:::%s"
  ],
  "Sid": ""
},
{
  "Action": [
"s3:GetObject"
  ],
  "Effect": "Allow",
  "Principal": {
"AWS": [
  "*"
]
  },
  "Resource": [
"arn:aws:s3:::%s/*"
  ],
  "Sid": ""
}
  ]
}
';
// If you want to put it on a specific folder you just change 'arn:aws:s3:::%s/*' to 'arn:aws:s3:::%s/folder/*'
// Create a bucket
$result = $s3->createBucket([
'Bucket' => $bucket_name,
]);
// Configure the policy
$s3->putBucketPolicy([
'Bucket' => $bucket_name,
'Policy' => sprintf($policyReadOnly, $bucket_name, $bucket_name),
]);
  8) You can store your object into your bucket using below.
$insert = $s3->putObject([
 'Bucket' => $bucket_name,
 'Key'    => 'file_name/folder_name',
 'Body'   => 'Hello from MinIO!!'
]);
  9) You can upload a file object into your bucket using below.
$result = $s3->putObject(array(
'Bucket'        =>  $bucket_name, // BucketName
'Key'           =>  $file_name,   // File Name
'SourceFile'    =>  $source // file full path
));
  10) You can get your object using the method below.
$retrieve = $s3->getObject([
'Bucket' => $bucket_name,
'Key' => $file_name
]);