SiaSia Developer Portal

Quickstart

Sia is a decentralized storage network where all data is encrypted client-side, erasure-coded into redundant shards, and distributed across independent storage providers worldwide. An indexer coordinates uploads, downloads, and object management without ever seeing your data.

Install the SDK

sh
cargo add sia_storage

Upload and Pin

Upload reads from any stream source, erasure-codes the data, and distributes encrypted shards across the network. Pinning persists the object record in the indexer so it becomes listable, syncable, and eligible for repair.

rust
use sia_storage::{Object, UploadOptions}; let reader = std::io::Cursor::new(b"hello, world!"); let obj = Object::default(); let obj = sdk.upload(obj, reader, UploadOptions::default()).await?; sdk.pin_object(&obj).await?; println!("Object ID: {}", obj.id());

Download

Download locates the object's shards, retrieves them from storage providers, verifies integrity, and decrypts the data locally. The decrypted bytes stream into any writable destination.

rust
use sia_storage::DownloadOptions; use tokio::io::AsyncReadExt; let (mut writer, mut reader) = tokio::io::duplex(64 * 1024); let download_fut = async { sdk.download(&mut writer, &obj, DownloadOptions::default()).await?; drop(writer); Ok::<(), Box<dyn std::error::Error>>(()) }; let read_fut = async { let mut bytes = Vec::new(); reader.read_to_end(&mut bytes).await?; Ok::<Vec<u8>, Box<dyn std::error::Error>>(bytes) }; let (_, bytes) = tokio::try_join!(download_fut, read_fut)?; println!("Downloaded: {}", String::from_utf8_lossy(&bytes));