ipfs_http_rpc 0.0.2 copy "ipfs_http_rpc: ^0.0.2" to clipboard
ipfs_http_rpc: ^0.0.2 copied to clipboard

outdated

Yet another IPFS (HTTP RPC) client implementation for Dart. This package allows easy access to IPFS methods over HTTP with clear documentation.

example/main.dart

// ignore_for_file: avoid_print
import 'package:ipfs_http_rpc/ipfs.dart';

void main() async {
  // Defaults to: Ipfs(url: "http://127.0.0.1:5001/api/v0").
  Ipfs ipfs = Ipfs();

  // Add a file that is locally stored.
  Map<String, dynamic> response = await ipfs.add(path: "example/file.txt");

  // If successful, response will have "Hash" key, but
  // it's also possible to check for "StatusMessage" or other
  // keys depending on the command.
  if (response.containsKey("Hash")) {
    final fileName = response["Name"];
    final fileHash = response["Hash"];

    print("Successfully added file '$fileName' to IPFS!");
    print("The file's hash is $fileHash");

    // Try to read the file's contents.
    Map<String, dynamic> catResponse = await ipfs.cat(path: "/ipfs/$fileHash");

    print(catResponse);
    // Should print:
    // {StatusCode: 200, StatusMessage: OK, Text: Hello!}
  } else {
    print("Couldn't add file to IPFS.");
    print("Response: $response");
  }
}
5
likes
0
points
17
downloads

Publisher

unverified uploader

Weekly Downloads

Yet another IPFS (HTTP RPC) client implementation for Dart. This package allows easy access to IPFS methods over HTTP with clear documentation.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

dio, flutter

More

Packages that depend on ipfs_http_rpc