|
17 | 17 |
|
18 | 18 | public class APITest {
|
19 | 19 | //http访问方式
|
20 |
| - //private final UDFS udfs = new UDFS("132.232.99.150",5001,false); |
| 20 | + private final UDFS udfs = new UDFS("132.232.99.150",5001,false); |
21 | 21 | //https访问方式
|
22 |
| - private final UDFS udfs = new UDFS("114.67.37.76",443,false); |
| 22 | + //private final UDFS udfs = new UDFS("114.67.37.76",443,false); |
23 | 23 | private final Random r = new Random(33550336); // perfect
|
24 | 24 |
|
25 | 25 | @Test
|
@@ -123,13 +123,27 @@ public void pushSingleFileTest() throws IOException {
|
123 | 123 | @Test
|
124 | 124 | public void pushFileTest() throws IOException {
|
125 | 125 | //要添加文件使用
|
126 |
| - NamedStreamable.FileWrapper file = new NamedStreamable.FileWrapper(new File("F:/test/20181116.txt")); |
| 126 | + /* NamedStreamable.FileWrapper file = new NamedStreamable.FileWrapper(new File("F:/test/20181116.txt")); |
127 | 127 | //添加文件到IPFS返回HASH值
|
128 | 128 | List<MerkleNode> addParts = udfs.add(file);
|
| 129 | + System.out.println("内容为:"+addParts.get(0).toJSONString());*/ |
| 130 | + /* String hash="QmPQJ6CTMxxGintCKKeQ38gxE8P9nnUdq5nM8nifLT1aQh"; |
| 131 | + //Multihash hash=new Multihash("QmPQJ6CTMxxGintCKKeQ38gxE8P9nnUdq5nM8nifLT1aQh"); |
| 132 | + List<Multihash> pinRm=udfs.pin.rm(Multihash.fromBase58("QmPQJ6CTMxxGintCKKeQ38gxE8P9nnUdq5nM8nifLT1aQh")); |
| 133 | + System.out.println("删除结果:"+pinRm.get(0).toString());*/ |
| 134 | + |
| 135 | + Multihash filePointer = Multihash.fromBase58("Qme7KYZZTkARzkwE4x3vLKC4zB1jtNdw5HwuCxqABE7Kgc"); |
| 136 | + byte[] fileContents = udfs.cat(filePointer); |
| 137 | + String str=new String(fileContents); |
| 138 | + System.out.println("查询的内容为:"+str); |
| 139 | + List<Multihash> pinRm=udfs.pin.rmlocal(filePointer); |
| 140 | + System.out.println("删除结果:"+pinRm.get(0).toString()); |
129 | 141 | //输出HASH值
|
130 |
| - |
131 | 142 | //List<MerkleNode> addParts = udfs.push(file);
|
132 |
| - System.out.println(addParts.get(0).hash); |
| 143 | + /* System.out.println("哈希值:"+addParts.get(0).hash); |
| 144 | + System.out.println("名称:"+addParts.get(0).name); |
| 145 | + System.out.println("文件大小"+addParts.get(0).largeSize); |
| 146 | + System.out.println("备份节点信息"+addParts.get(0).backup);*/ |
133 | 147 | }
|
134 | 148 |
|
135 | 149 | @Test
|
|
0 commit comments