Using Python & boto3
Build Python applications with boto3 and the S3 adapter.
Run the adapter
Start the adapter with the binary installed and flags described in the installation page.
This will start the adapter on port 8014
by default. Also, recall the --network
flag can,
optionally, be provided to point to a specific Recall chain environment, and logging can be enabled
by passing the -v
flag.
You MUST own tokens and credits to create a bucket and store data, respectively. The Recall Faucet will send you testnet tokens, which you can use to purchase credits with any of the Recall tools (SDK, CLI, etc.). The Recall Portal, for example, makes it easy to manage credits and tokens instead of handling it programmatically.
Create helper functions
Create a connection
First, we'll import the necessary modules and define a helper function to connect to the adapter:
Create a bucket
Our bucket creation helper does one important thing: it prefixes the bucket name with the creator's public key. This is optional, as described in the bucket usage docs. You could choose to simply use the alias name you define upon creation.
Interact with objects
The following functions interact with objects in the bucket, including writing, listing, and getting objects.
Connect, write, and read data
The example below demonstrates how to connect to the adapter, create a bucket, and interact with objects. It establishes a connection, creates a bucket, writes a simple key/value pair, and then reads it back.
The one callout is the OWNER_ADDRESS
environment variable.