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
Python 3 in your development environment.
the AWS SDK for Python (Boto3).
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.
# 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 , or send us an email at .