A lightweight, extensible IPFS peer for iOS.
IPFS Lite runs the minimal setup required to get and put IPLD DAGs on the IPFS network. It is a port of the Go IPFS Lite library.
IPFS Lite runs the minimal setup required to provide a DAG service. It is a port of the Go IPFS Lite library, and as such, has the same requirements. The goal of IPFS Lite is to run the bare minimal functionality for any IPLD-based application to interact with the IPFS network (by getting and putting blocks). This saves having to deal with the complexities of using a full IPFS daemon, while maintaining the ability to share the underlying libp2p host and DHT with other components.
The following includes information about support for ipfs-lite.
Name | Build | Language | Description |
---|---|---|---|
ipfs-lite |
The reference implementaiton of ipfs-lite, written in Go. | ||
js-ipfs-lite |
The Javascript version of ipfs-lite available for web, nodejs, and React Native applications. | ||
ios-ipfs-lite |
The iOS ipfs-lite library for use in Objc and Swift apps | ||
android-ipfs-lite |
The Java ipfs-lite library for us in Android apps | ||
grpc-ipfs-lite |
A common gRPC API interface that runs on the Go ipfs-lite node. |
- Launch IPFS Lite
- Stop IPFS Lite
-
addFileFromInput:params:completion:
Add data viaNSInputStream
. -
getFileWithCid:completion:
Asynchronously get file by content address. -
getFileToOutput:cid:completion:
Asynchronously get file by content address and write it to aNSOutputStream
-
getNodeForCid:completion:
Asynchronously get an IPLD node from IPFS. -
getNodesForCids:completion:
Get multiple IPLD nodes. -
hasBlock:completion:
Query if the local peer has the specified block -
removeNodeForCid:completion:
Remove an IPLD node. -
removeNodesForCids:completion:
Remove multiple IPLD nodes. -
resolveLinkInNodeWithCid:path:completion:
Resolve a link though a path in an IPLD node. -
treeInNodeWithCid:fromPath:depth:completion:
List all data paths in an IPLD node. -
addNode
And an IPLD node. -
addNodes
And multiple IPLD nodes.
The IPFS Lite library is published as a Cocoapod.
First, you'll need to configure your project to use Cocoapods.
Then, simple add IpfsLiteApi
to your Podfile
...
pod 'IpfsLiteApi'
...
and run pod install
NSString *documents = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *repoPath = [documents stringByAppendingPathComponent:@"ipfs-lite"];
NSError *error;
BOOL success = [IpfsLiteApi launch:repoPath debug:false lowMem: true error:&error];
NSInputStream *input = [[NSInputStream alloc] initWithData:[@"Hello there\n" dataUsingEncoding:NSUTF8StringEncoding]];
[IpfsLiteApi.instance addFileFromInput:input parms:[[TTEAddParams alloc] init] completion:^(Node * _Nullable node, NSError * _Nullable error) {
// handle the node or error
}];
NSString *path = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"jpeg"];
NSInputStream *input = [[NSInputStream alloc] initWithFileAtPath:path];
[IpfsLiteApi.instance addFileFromInput:input params:[[TTEAddParams alloc] init] completion:^(Node * _Nullable node, NSError * _Nullable error) {
// handle the node or error
}];
NSString *documents = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *outputPath = [documents stringByAppendingPathComponent:@"out.jpeg"];
NSOutputStream *output = [NSOutputStream outputStreamToFileAtPath:outputPath append:NO];
[IpfsLiteApi.instance getFileToOutput:output cid:@"<a-file-cid>" completion:^(NSError * _Nullable error) {
// Handle error if it exists or interact with data written to disk
}];
[IpfsLiteApi.instance getNodeForCid:@"QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D" completion:^(Node * _Nullable node, NSError * _Nullable error) {
// handle the node or error
}];
PRs accepted.
Small note: If editing the README, please conform to the standard-readme specification.
MIT (c) 2019 Textile