-
Notifications
You must be signed in to change notification settings - Fork 3
Constellation IPFS
Sara Tavares edited this page Nov 17, 2022
·
1 revision
Installing IPFS Desktop Installing IPFS CLIRecommended
Note: IPFS is required to be installed and running on your machine to use this extension at this time.
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_ipfs"] }
use warp::constellation::Constellation;
use warp_extensions::fs_ipfs::IpfsFileSystem;
let mut system = IpfsFileSystem::new();
If you have a custom URL to IPFS API server you can do the following
let mut system = IpfsFileSystem::new_with_uri("https://127.0.0.1:5001").unwrap();
Upload Content
use warp::constellation::Constellation;
use warp_extensions::fs_ipfs::IpfsFileSystem;
let mut system = IpfsFileSystem::new();
system.from_buffer("new_file", &b"This is content to the file".to_vec()).await.unwrap();
use warp::constellation::Constellation;
use warp_extensions::fs_ipfs::IpfsFileSystem;
let mut system = IpfsFileSystem::new();
let mut buffer = vec![];
system.to_buffer("new_file", &mut buffer).await.unwrap();
println!("{}", String::from_utf8_lossy(&buffer));