AWS SDK - Python

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

Preparation

Development Examples

Create a bucket

endpoint_url: 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 name for creating the bucket

import boto3

s3 = boto3.client('s3',
        endpoint_url='https://endpoint.4everland.co',
        aws_access_key_id="4EVERLAND-Bucket-APIKey",
        aws_secret_access_key="4EVERLAND-Bucket-APISecret")

bucket_name = "new-bucketname"

s3.create_bucket(Bucket=bucket_name)

View the list of buckets

# Retrieve the list of existing buckets
s3 = boto3.client('s3',
        endpoint_url='https://endpoint.4everland.co',
        aws_access_key_id="4EVERLAND-Bucket-APIKey",
        aws_secret_access_key="4EVERLAND-Bucket-APISecret")
response = s3.list_buckets()
# Output the bucket names
print('Existing buckets:')
for bucket in response['Buckets']:
    print(f'  {bucket["Name"]}')

Upload a file

bucket_name: Your bucket name

object_name: The file path for upload

import boto3

s3 = boto3.client('s3',
        endpoint_url='https://endpoint.4everland.co',
        aws_access_key_id="4EVERLAND-Bucket-APIKey",
        aws_secret_access_key="4EVERLAND-Bucket-APISecret")
        
with open("4ever.png", "rb") as 4ever:
    s3.upload_fileobj(4ever, "bucket_name", "object_name")

Requesting IPFS CID and Arweave Hash

BucketName: The bucket name where the target file is stored

Key: The path of the target file

import boto3
s3client = boto3.client('s3',
        endpoint_url='https://endpoint.4everland.co',
        aws_access_key_id="4EVERLAND-Bucket-APIKey",
        aws_secret_access_key="4EVERLAND-Bucket-APISecret")

        metadata = s3client.head_object(Bucket='BucketName', Key=file['Key'])
        print(metadata['ipfs-hash'])
        #If it is an Arweave type of bucke
        print(metadata['arweave-hash'])
      

If you have any questions, please join our Discord server, or send us an email at contact@4everland.org.

Last updated