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
  • Create a bucket
  • Upload a file
  • Requesting IPFS CID and Arweave Hash
  1. Storage
  2. Bucket
  3. Bucket API - S3 Compatible
  4. Coding Examples

AWS SDK - Ruby

Last updated 1 year ago

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

Preparation

  • in your development environment.

  • the AWS SDK for Ruby in your development environment.

  • 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

Create a bucket

endpoint: https://endpoint.4everland.co

aws_access_key_id: Bucket-Access Keys-API key

aws_secret_access_key: Bucket-Access Keys-API Secret

bucket_name: The desired bucket name to create

require 'aws-sdk-s3'

s3 = Aws::S3::Client.new(
access_key_id: '4EVERLAND-Bucket-APIKey',
secret_access_key: '4EVERLAND-Bucket-APISecret',
region: '4everland',
endpoint: 'https://endpoint.4everland.co'
)

bucket_name = 'new-bucketname'
s3.create_bucket(bucket: bucket_name)

Upload a file

bucket_name: Your bucket name

object_key: The name of the file to be uploaded

object_path: The path of the file to be uploaded

require 'aws-sdk-s3'

s3 = Aws::S3::Client.new(
access_key_id: '4EVERLAND-Bucket-APIKey',
secret_access_key: '4EVERLAND-Bucket-APISecret',
region: '4everland',
endpoint: 'https://endpoint.4everland.co'
)

bucket_name = '4everland-bucketname'
object_key = 'object-name'
object_path = '/path/to/4everland/4ever.png'

File.open(object_path, 'rb') do |file|
s3.put_object(bucket: bucket_name, key: object_key, body: file)
end

Requesting IPFS CID and Arweave Hash

endpoint: https://endpoint.4everland.co

aws_access_key_id: Bucket-Access Keys-API Key

aws_secret_access_key: Bucket-Access Keys-API Secret

bucket_name: The bucket name where the target file is stored

object_name: The name of the target file

require 'aws-sdk-s3'
  
Aws3 = Aws::S3::Client.new(
    access_key_id: '4EVERLAND-Bucket-APIKey',
    secret_access_key: '4EVERLAND-Bucket-APISecret',
    region: '4everland',
    endpoint: 'https://endpoint.4everland.co'
)

bucket_name = '4everland-bucketname'
object_name = 'your-object-name'

s3 = Aws3::S3::Resource.new

begin
  obj = s3.bucket(bucket_name).object(object_name)
  metadata = obj.metadata
  ipfs_hash = metadata['ipfs-hash']
  arweave_hash = metadata['arweave-hash']
  puts "IPFS Hash: #{ipfs_hash}"
  #If it is an Arweave type of bucke
  puts "Arweave Hash: #{arweave_hash}"

rescue Aws::S3::Errors::NoSuchKey
  puts "File does not exist"
rescue StandardError => e
  puts "An error occurred:#{e.message}"
end

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

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