Skip to content

exmgr/ipfs-client-esp32

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IPFS Client ESP32 Arduino Library

ESP32 library for interacting with IPFS. Requires ArduinoJSON.

Usage

Initialize IPFS client object

WiFiClient wifi_client();
IPFSClient ipfs_client(wifi_client);
ipfs_client.set_node_address([ipfs node address], 5001);

IPFS 'add'

Add text file

IPFSClient::IPFSFile ipfs_file; // Parsed return parameters

ipfs_client.add(&ipfs_file, "file.txt", "Lorem IPFSum");

// Resulting CID is in ipfs_file.hash

Add binary file

IPFSClient::IPFSFile ipfs_file; // Parsed return parameters

// Open file in SPIFFS
f = SPIFFS.open("/file_in_spiffs.png", "r");
ipfs_client.add(&ipfs_file, "file.png", &f);

// Resulting CID is in ipfs_file.hash

IPFS 'cat'

Read data from file.

IPFSClient::Result = ipfs_client.cat("[IPFS CID here]", output);

Check /examples for more.

IPFS 'cp' / 'mv/

cp copy file from IPFS to the Mutable File System, or between MFS directories. mv move file between MFS directories.

IPFSClient::Result result = ipfs_client.files_mv("/path/to/source/file", "/path/to/destination");

IPFS 'stat'

Get file status

StaticJsonDocument<200> json;
IPFSClient::Result res = ipfs_client.files_stat("/path/to/file", json);

Serial.print(F("Hash: "));
Serial.println(doc["Hash"].as<char*>());
Serial.print(F("Size: "));
Serial.println(doc["Size"].as<int>(), DEC);
Serial.print(F("Type: "));
Serial.println(doc["Type"].as<char*>());

About

ESP32 Arduino library for adding/getting files to IPFS

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages