File tree Expand file tree Collapse file tree 3 files changed +21
-3
lines changed Expand file tree Collapse file tree 3 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -48,9 +48,10 @@ internal ConfigApi(IpfsClient ipfs)
48
48
return ;
49
49
}
50
50
51
- public Task ReplaceAsync ( JObject config )
51
+ public async Task ReplaceAsync ( JObject config )
52
52
{
53
- throw new NotImplementedException ( ) ;
53
+ var data = Encoding . UTF8 . GetBytes ( config . ToString ( Formatting . None ) ) ;
54
+ await ipfs . UploadAsync ( "config/replace" , CancellationToken . None , data ) ;
54
55
}
55
56
}
56
57
Original file line number Diff line number Diff line change 27
27
</PropertyGroup >
28
28
29
29
<ItemGroup >
30
- <PackageReference Include =" Ipfs.Core" Version =" 0.34.0 " />
30
+ <PackageReference Include =" Ipfs.Core" Version =" 0.34.1 " />
31
31
<PackageReference Include =" Newtonsoft.Json" Version =" 11.0.2" />
32
32
<PackageReference Include =" System.Net.Http" Version =" 4.3.3" Condition =" '$(TargetFramework)' == 'netstandard14'" />
33
33
<PackageReference Include =" System.Net.Http" Version =" 4.3.3" Condition =" '$(TargetFramework)' == 'net45'" />
Original file line number Diff line number Diff line change 3
3
using Newtonsoft . Json . Linq ;
4
4
using System ;
5
5
using System . Text ;
6
+ using System . Threading . Tasks ;
6
7
7
8
namespace Ipfs . Api
8
9
{
@@ -68,5 +69,21 @@ public void Set_JSON_Value()
68
69
Assert . AreEqual ( "http://example.io" , ipfs . Config . GetAsync ( key ) . Result [ 0 ] ) ;
69
70
}
70
71
72
+ [ TestMethod ]
73
+ public async Task Replace_Entire_Config ( )
74
+ {
75
+ IpfsClient ipfs = TestFixture . Ipfs ;
76
+ var original = await ipfs . Config . GetAsync ( ) ;
77
+ try
78
+ {
79
+ var a = JObject . Parse ( "{ \" foo-x-bar\" : 1 }" ) ;
80
+ await ipfs . Config . ReplaceAsync ( a ) ;
81
+ }
82
+ finally
83
+ {
84
+ await ipfs . Config . ReplaceAsync ( original ) ;
85
+ }
86
+ }
87
+
71
88
}
72
89
}
You can’t perform that action at this time.
0 commit comments