Load.Network provides an S3 implementation which enables developers to store files permanently in a decentralized manner by using the common AWS S3 Patterns with minimal change.
Load.Network is compatible with the S3 SDKs, because of this, you are able to use existing libraries.
To install the official S3 library in NodeJS, run the following command
$ yarn add @aws-sdk/client-s3In order to initialize the S3 client connected to Load Network, you can do the following:
import{S3Client}from"@aws-sdk/client-s3";constaccessKeyId=process.env.LOAD_ACCESS_KEY;constsecretAccessKey="";// It's meant to be emptyconsts3Client=newS3Client({region: "eu-west-2",// Required -- current supported regionendpoint: "https://s3.load.rs",// Load.Network S3 endpointcredentials: {
accessKeyId,
secretAccessKey,},forcePathStyle: true,// Required});process.env.LOAD_ACCESS_KEY: Contains your private service key in cloud.load.network.- It looks similar to
load_acc_*******
- It looks similar to
https://s3.load.rsis the endpoint for the S3 interface provided by Load -- codebaseforcePathStyleset totrueis always necessary.- (optional) use
"uploader-api": "turbo"is the command metadata object to push the object data to Arweave via Turbo. Default is load0.
use aws_sdk_s3::error::SdkError;use aws_sdk_s3::operation::create_bucket::CreateBucketError;use aws_sdk_s3::Client;pubasyncfncreate_client() -> Client{let config = aws_config::from_env().endpoint_url("https://s3.load.rs").region("eu-west-2").load().await;let s3_config = aws_sdk_s3::config::Builder::from(&config).force_path_style(true).build();Client::from_conf(s3_config)}pubasyncfns3_create_bucket() -> Result<(),SdkError<CreateBucketError>>{let client = create_client().await;match client.create_bucket().bucket("LoadNetworkBucketTest").send().await{Ok(output) => {println!("✅ Bucket created: {}", output.location().unwrap_or("(no location)"));Ok(())},Err(err) => {println!("❌ Error creating bucket: {}", err);Err(err)}}}for more examples, checkout this rust-examples.
This repository is licensed under the MIT License