> For the complete documentation index, see [llms.txt](https://docs.4everland.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.4everland.org/storage/bucket/bucket-api-s3-compatible/coding-examples/aws-sdk-python.md).

# 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**

* [Download and install](https://www.python.org/downloads/) Python 3 in your development environment.
* [Download and install](https://github.com/boto/boto3#getting-started) the AWS SDK for Python (Boto3).
* [Register](https://www.4everland.org/) a free 4EVERLAND account.
* If you need to use Arweave storage, you need to create an Arweave bucket. Click to[ ](https://docs.4everland.org/storage/bucket/bucket-api-s3-compatible)[learn more](https://docs.4everland.org/storage/bucket/guides).
* To obtain the corresponding API key in the bucket, click to[ learn more](https://docs.4everland.org/storage/bucket/bucket-api-s3-compatible).

## 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

```python
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

```python
# 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

```python
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

```python
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'])
      
```

{% hint style="info" %}
If you have any questions, please join our [Discord server](https://discord.com/invite/Cun2VpsdjF), or send us an email at <contact@4everland.org>.
{% endhint %}
