Net::Ethereum::Swarm - Perl Framework for a distributed storage platform and content distribution service Ethereum Swarm.
# Upload text file to Ethereum Swarm
use Net::Ethereum::Swarm; my $uploaded_file_path = $ARGV[0]; my $sw_node = Net::Ethereum::Swarm->new('http://localhost:8500/'); my $rc = $sw_node->_swarp_node_upload_text_file($uploaded_file_path, 'plain/text; charset=UTF-8'); print Dumper($rc), "\n";
# Upload binary file to Ethereum Swarm
use Net::Ethereum::Swarm; my $uploaded_file_path = $ARGV[0]; my $sw_node = Net::Ethereum::Swarm->new('http://localhost:8500/'); my $rc = $sw_node->_swarp_node_upload_binary_file($uploaded_file_path, 'image/jpeg'); print Dumper($rc), "\n";
# Get manifest by manifest id
use Net::Ethereum::Swarm; my $manifest_id = $ARGV[0]; my $sw_node = Net::Ethereum::Swarm->new('http://localhost:8500/'); my $rc = $sw_node->_swarp_node_get_manifest($manifest_id); print Dumper($rc), "\n";
# Get file from Ethereum Swarm
use Net::Ethereum::Swarm; my $manifest_id = $ARGV[0]; my $file_path_to_save = $ARGV[1]; my $sw_node = Net::Ethereum::Swarm->new('http://localhost:8500/'); my $rc = $sw_node->_swarp_node_get_file($manifest_id, $file_path_to_save, 'plain/text; charset=UTF-8'); print Dumper($rc), "\n";
my $sw_node = Net::Ethereum::Swarm->new('http://localhost:8500/');
Get manifest by manifest id my $rc = $sw_node->_swarp_node_get_manifest($manifest_id);
Get file from Ethereum Swarm my $rc = $sw_node->_swarp_node_get_file($manifest_id, $file_path_to_save, 'plain/text; charset=UTF-8');
Upload text file to Ethereum Swarm my $rc = $sw_node->_swarp_node_upload_text_file($uploaded_file_path, 'plain/text; charset=UTF-8');
Upload binary file to Ethereum Swarm my $rc = $sw_node->_swarp_node_upload_binary_file($uploaded_file_path, 'image/jpeg');
Internal method. Send request to Ethereum Swarm my $ua_rc = $this->_swarp_node_request('POST', 'bzz:/', $header, $file_content);
Set dubug mode. Debug info printed to console. $node->set_debug_mode($mode); $mode: 1 - debug on, 0 - debug off.
Swarm documentation: https://swarm-guide.readthedocs.io/en/latest/index.html
GitHub Swarm guide: https://github.com/ethersphere/swarm-guide/blob/master/contents/usage.rst
Swarm API improvements : https://gist.github.com/lmars/a37f3eaa129f95273c8c536e98920368
Alexandre Frolov, frolov@itmatrix.ru L<https://www.facebook.com/frolov.shop2you> The founder and director of SAAS online store service Shop2YOU, L<http://www.shop2you.ru>
Copyright (C) 2018 by Alexandre Frolov This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.26.0 or, at your option, any later version of Perl 5 you may have available.
To install Net::Ethereum::Swarm, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::Ethereum::Swarm
CPAN shell
perl -MCPAN -e shell install Net::Ethereum::Swarm
For more information on module installation, please visit the detailed CPAN module installation guide.