-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test python scripts put and get file form ipfs
- Loading branch information
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/env python | ||
# python2.7.16 | ||
|
||
import ipfsapi | ||
import sys | ||
|
||
|
||
def main(): | ||
if len(sys.argv) < 3 : | ||
print "args error\nUsage: ./py-ipfs-api.py ${ipaddress} add gettestfile.py" | ||
sys.exit(1) | ||
|
||
if sys.argv[2] == "get" : | ||
api = ipfsapi.connect(sys.argv[1], 5001) | ||
for file in sys.argv[3:] : | ||
res = api.get(file) | ||
print res | ||
|
||
if sys.argv[2] == "add" : | ||
api = ipfsapi.connect(sys.argv[1], 5001) | ||
for file in sys.argv[3:] : | ||
res = api.add(file) | ||
print res | ||
|
||
if __name__ == "__main__": | ||
main() |