The Borg library abstracts away the protocols and `libp2p` connection, and exposes APIs similar to MongoDB
for data persistence and S3 for file storage
Use Server with caution and know the risk's because we are at development stage and the identity and encryption is not available, so you become public node that can accessed from anywhere.
Install NPM package
npm install @functionland/borg --save
or using CDN
<script src="https://cdn.jsdelivr.net/npm/@functionland/borg/dist/index.js"></script>
Start borg and use file storage of borg-server
import {Borg, createClient} from '@functionland/borg'
// Create a borg client
const borgClient = await createClient();
// ...
// connect to a borg server by its base58 string PeerId
await borgClient.connect(serverId)
// send file and get cid
// selectedFile send file use StreamReader interface or AsyncItrable and get cid
// meta {name,type,lastModified,size}
const FileCid = await borgClient.sendStreamFile(selectedFile,meta);
// recive meta data
const data = await borgClient.receiveMeta(fileId);
// recive file using cid
const data = await borgClient.receiveFile(FileCid);
let reader = new FileReader();
reader.readAsDataURL(data);
reader.onloadend = (e) => setContent(reader.result)
For more examples, please refer to the Examples
- Protocols
- File
- Data
- AI
- Identity
- Encryption
See the open issues for a full list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
See LICENSE
for more information.