4EVERLAND Documents
HomeTwitterDiscordBlogs
  • Welcome to 4EVERLAND
  • Get started
    • Our Features
    • Quick Start Guide
      • Registration
      • Login options
        • MetaMask
        • OKX Wallet
        • Binance Web3 Wallet
        • Bitget Wallet
        • Phantom
        • Petra
        • Lilico
      • Usage Introduction
      • Dashboard stats
      • Account
        • Linking Your EVM Wallet to 4EVERLAND Account
        • Balance Alert
    • Billing and Pricing
      • What is LAND?
      • How to Obtain LAND?
      • Pricing Model
      • Q&As
    • Tokenomics
  • HOSITNG
    • What is Hosting?
      • IPFS Hosting
      • Arweave Hosting
        • Auto-Generation of Manifest
      • Internet Computer Hosting
      • Greenfield Hosting
    • Guides
      • Creating a Deployment
        • With Git
        • With IPFS Hash
        • With a Template
      • Site Deployment
      • Domain Management
        • DNS Setup Guide
        • ENS Setup Guide
        • SNS Setup Guide
          • The gateway: 4sol.xyz
        • SPACE ID Setup Guide
      • Project Setting
        • Git
      • Troubleshooting
      • Common Frameworks
    • Hosting Templates Centre
      • Templates Configuration File
    • Quick Addition
      • Implement Github 4EVER Pin
      • Github Deployment Button
    • Hosting API
      • Create Project API
      • Deploy Project API
      • Get Task Info API
      • IPNS Deployment Update API
    • Hosting CLI
  • Storage
    • Bucket
      • IPFS Bucket
        • Get Root CID - Snapshots
      • Arweave Bucket
        • Path Manifests
          • Instructions for Building Manifest
          • Auto-Generation of Manifest
        • Arweave Tags
        • Unleash Arweave
      • Guides
      • Bucket API - S3 Compatible
        • Coding Examples
          • AWS SDK - Go (Golang)
          • AWS SDK - Java
          • AWS SDK - JavaScript
          • AWS SDK - .NET
          • AWS SDK - PHP
          • AWS SDK - Python
          • AWS SDK - Ruby
        • S3 Tags Instructions
      • 4EVER Security Token Service API
      • Bucket Tools
      • Bucket Gateway Optimizer
    • 4EVER Pin
      • Guides
      • Pinning Services API
      • IPFS Migrator
    • Storage SDK
  • Gateways
    • IPFS Gateway
    • IC Gateway
    • Arweave Gateway
    • Dedicated Gateways
      • Gateway Access Controls
      • Video Streaming
      • IPFS Image Optimizer
    • IPNS Manager
      • IPNS Manager API
  • RPC
    • Guides
    • API Keys
    • JSON Web Token (JWT)
    • What's CUs/CUPS
    • WebSockets
    • Archive Node
    • Debug API
    • Chains RPC
      • BSC / opBNB
      • Ethereum
      • Optimism
      • Polygon
      • Taiko
  • AI
    • AI RPC
      • Quick Start
      • Models
      • API Keys
      • Requests & Responses
      • Parameters
    • 4EVER Chat
  • RaaS - Beta
    • What's Rollups?
    • 4EVER Rollup Stack
  • DePIN
    • 4EVER Network
    • Storage Nodes
  • More
    • Use Cases
      • Livepeer
      • Lens Protocol
      • Optopia.ai
      • Linear Finance
      • Snapshot
      • Tape
      • Taiko
      • Hey.xyz
      • SyncSwap
    • Community
    • Tutorials
    • Security
    • 4EVERLAND FAQ
Powered by GitBook
On this page
  • Preparation
  • Development Examples
  • Set the environment variables
  • Configure the parameters within the environment variables
  • Create a bucket
  • Upload a file
  • Check the files in the bucket
  • Requesting IPFS CID and Arweave Hash
  1. Storage
  2. Bucket
  3. Bucket API - S3 Compatible
  4. Coding Examples

AWS SDK - PHP

Last updated 1 year ago

Please read the following to understand how to use the 4EVERLAND Bucket with AWS SDK - PHP. This guide outlines the integration of AWS SDK API for PHP with the 4EVERLAND Bucket to facilitate file uploads to the IPFS or Arweave storage networks.

Preparation

  • PHP in your development environment.

  • the AWS SDK for PHP version 3.

  • a free 4EVERLAND account.

  • If you need to use Arweave storage, you need to create an Arweave bucket. Click to.

  • To obtain the corresponding API key in the bucket, click to.

Development Examples

Set the environment variables

4everland-Access-Key:Bucket-Access Keys-API Key

4everland-Secret-Key:Bucket-Access Keys-API Secret

Linux/Mac OS x:

export 4EVERLAND_ACCESS_KEY_ID=[4everland-Access-Key]

export 4EVERLAND_SECRET_ACCESS_KEY=[4everland-Secret-Key]

Windows:

SET 4EVERLAND_ACCESS_KEY_ID=[4everland-Access-Key]

SET 4EVERLAND_SECRET_ACCESS_KEY=[4everland-Secret-Key]

Configure the parameters within the environment variables

use Aws\Credentials\CredentialProvider;
use Aws\S3\S3Client;

// Use the default credential provider
$provider = CredentialProvider::defaultProvider();

// Pass the provider to the client
$client = new S3Client([
    'endpoint'    => 'https://endpoint.4everland.co',
    'region'      => '4everland',
    'version'     => 'latest',
    'credentials' => $provider
]);

Create a bucket

Region: Fill in the default value as "4everland"

Bucket: Specify the desired name for the Bucket during creation

$s3client = new Aws\S3\S3Client(['region' => '4everland', 'version' => 'latest']);

try {
    $s3client->createBucket([
        'Bucket' => $bucket_name,
        'CreateBucketConfiguration' => ['LocationConstraint' => $region],
    ]);
    echo "Created bucket named: $bucket_name \n";
} catch (Exception $exception) {
    echo "Failed to create bucket $bucket_name with error: " . $exception->getMessage();
    exit("Please fix error with bucket creation before continuing.");
}

Upload a file

Bucket: Your bucket name

Key: Provide the filename for the file you want to upload

SourceFile: Provide the path to the file you want to upload

$s3client = new Aws\S3\S3Client(['region' => '4everland', 'version' => 'latest']);

$file_name = "local-file-" . uniqid();
try {
    $s3client->putObject([
        'Bucket' => $bucket_name,
        'Key' => $file_name,
        'SourceFile' => '/path/to/4everland/4ever.png'
    ]);
    echo "Uploaded $file_name to $bucket_name.\n";
} catch (Exception $exception) {
    echo "Failed to upload $file_name with error: " . $exception->getMessage();
    exit("Please fix error with file upload before continuing.");
}

Check the files in the bucket

Bucket: Your bucket name

$s3client = new Aws\S3\S3Client(['region' => '4everland', 'version' => 'latest']);

try {
    $contents = $s3client->listObjects([
        'Bucket' => $bucket_name,
    ]);
    echo "The contents of your bucket are: \n";
    foreach ($contents['Contents'] as $content) {
        echo $content['Key'] . "\n";
    }
} catch (Exception $exception) {
    echo "Failed to list objects in $bucket_name with error: " . $exception->getMessage();
    exit("Please fix error with listing objects before continuing.");
}

Requesting IPFS CID and Arweave Hash

Bucket: Your bucket name

Key: Specify the path of the target object

$result = $client->headObject([
    'Bucket' => '4everlandbucket', 
    'Key' => '/path/to/4everland/4ever.png', 
]);

echo "ipfs cid:" . $result["Metadata"]["ipfs-hash"]
//If it is an Arweave type of bucke
echo "arweave hash:" . $result["Metadata"]["arweave-hash"]

If you have any questions, please join our , or send us an email at .

Download and install
Download and install
Register
learn more
learn more
Discord server
contact@4everland.org