-
Notifications
You must be signed in to change notification settings - Fork 3
Constellation Storj
Sara Tavares edited this page Nov 17, 2022
·
1 revision
Please review on how to obtain the Access Key, and Secret Key
In your cargo project add the following
[dependencies]
warp = { git = "https://github.com/Satellite-im/Warp" }
warp_extensions = { git = "https://github.com/Satellite-im/Warp", features = ["fs_storj"] }
Via warp-tesseract
use warp::tesseract::Tesseract;
let mut tesseract = Tesseract::default();
tesseract.unlock(&b"<PASSWORD/KEY HERE>").unwrap();
tesseract.set("STORJ_ACCESS_KEY", "<ACCESS_KEY_HERE>").unwrap();
tesseract.set("STORJ_SECRET_KEY", "<SECRET_KEY_HERE>").unwrap();
//Save to a file
tesseract.to_file("datastore").unwrap();
You can confirm the contents of the datastore file by running
let mut tesseract = Tesseract::from_file(warp_directory.join("datastore")).unwrap_or_default();
tesseract.unlock(&b"<PASSWORD/KEY HERE>").unwrap();
let access_key = tesseract.retrieve("STORJ_ACCESS_KEY").unwrap();
let secret_key = tesseract.retrieve("STORJ_SECRET_KEY").unwrap();
Via Warp CLI
To add your keys to tesseract via the warp command line, run
warp import STORJ_ACCESS_KEY <ACCESS_KEY_HERE>
warp import STORJ_SECRET_KEY <SECRET_KEY_HERE>
You will be prompted for a password to use that will encrypt your keys. Once stored, you can view them by running
warp dump
This will show all the keys stored in tesseract after entering your password.
Via CLI
TODO
Uploading Content
use warp::constellation::Constellation;
use warp_extensions::fs_ipfs::IpfsFileSystem;
let mut tesseract = Tesseract::from_file(warp_directory.join("datastore")).unwrap_or_default();
tesseract.unlock(&b"<PASSWORD/KEY HERE>").unwrap();
let access_key = tesseract.retrieve("STORJ_ACCESS_KEY").unwrap();
let secret_key = tesseract.retrieve("STORJ_SECRET_KEY").unwrap();
let mut system = StorjFilesystem::new(access_key, secret_key);
system.from_buffer("new_file", &b"This is content to the file".to_vec()).await.unwrap();
let mut tesseract = Tesseract::from_file(warp_directory.join("datastore")).unwrap_or_default();
tesseract.unlock(&b"<PASSWORD/KEY HERE>").unwrap();
let access_key = tesseract.retrieve("STORJ_ACCESS_KEY").unwrap();
let secret_key = tesseract.retrieve("STORJ_SECRET_KEY").unwrap();
let mut system = StorjFilesystem::new(access_key, secret_key);
let mut buffer = vec![];
system.to_buffer("new_file", &mut buffer).await.unwrap();
println!("{}", String::from_utf8_lossy(&buffer));
let tesseract = Tesseract::from_file(warp_directory.join("datastore")).unwrap_or_default();
tesseract.unlock(&b"<PASSWORD/KEY HERE>").unwrap();
let access_key = tesseract.retrieve("STORJ_ACCESS_KEY").unwrap();
let secret_key = tesseract.retrieve("STORJ_SECRET_KEY").unwrap();
let mut system = StorjFilesystem::new(access_key, secret_key);
system.sync_ref().unwrap(); // To make sure the link is up to date
let file = system.current_directory().get_item("new_item").and_then(warp::item::Item::get_file).unwrap();
println!("{}", file.reference());