Skip to content

Commit 6e0f281

Browse files
committed
refactored some code and added feature
[ # ] SubClient.post_blog now accepts IEnumerable<byte[]> instead of List type [ # ] SubClient.post_wiki now accepts IEnumerable<byte[]> instead of List type [ # ] SubClient.edit_blog now accepts IEnumerable<byte[]> instead of List type [ + ] Added ability to pass Links into Client.upload_media(string), this allows people to pass custom media URLs into Amino Media
1 parent fef89ba commit 6e0f281

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

Amino.NET/Client.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44
using System.Globalization;
55
using System.IO;
66
using System.Linq;
7+
using System.Net.Http;
78
using System.Text;
89
using System.Threading;
910
using System.Threading.Tasks;
10-
using System.Threading.Tasks.Dataflow;
11-
using Amino.Objects;
1211
using Newtonsoft.Json;
1312
using Newtonsoft.Json.Linq;
1413
using RestSharp;
@@ -1416,6 +1415,11 @@ public Task flag_community(string communityId, string reason, Types.Flag_Types f
14161415
/// <returns>string : The URL to the media file you just uploaded</returns>
14171416
public string upload_media(string filePath, Types.upload_File_Types type)
14181417
{
1418+
if(filePath.StartsWith("http"))
1419+
{
1420+
byte[] fileBytes = new HttpClient().GetAsync(filePath).Result.Content.ReadAsByteArrayAsync().Result;
1421+
return upload_media(fileBytes, type);
1422+
}
14191423
return upload_media(File.ReadAllBytes(filePath), type);
14201424
}
14211425

Amino.NET/SubClient.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public Task delete_invite_code(string inviteId)
147147
/// <param name="fansOnly"></param>
148148
/// <param name="backgroundColor"></param>
149149
/// <returns></returns>
150-
public Task post_blog(string title, string content, List<byte[]> imageList = null, bool fansOnly = false, string backgroundColor = null)
150+
public Task post_blog(string title, string content, IEnumerable<byte[]> imageList = null, bool fansOnly = false, string backgroundColor = null)
151151
{
152152
JArray mediaList = new JArray();
153153
JObject extensionData = new JObject();
@@ -200,7 +200,7 @@ public Task post_blog(string title, string content, List<byte[]> imageList = nul
200200
/// <param name="fansOnly"></param>
201201
/// <param name="backgroundColor"></param>
202202
/// <returns></returns>
203-
public Task post_wiki(string title, string content, List<byte[]> imageList = null, bool fansOnly = false, string backgroundColor = null)
203+
public Task post_wiki(string title, string content, IEnumerable<byte[]> imageList = null, bool fansOnly = false, string backgroundColor = null)
204204
{
205205
JArray mediaList = new JArray();
206206
JObject extensionData = new JObject();
@@ -249,7 +249,7 @@ public Task post_wiki(string title, string content, List<byte[]> imageList = nul
249249
/// <param name="fansOnly"></param>
250250
/// <param name="backgroundColor"></param>
251251
/// <returns></returns>
252-
public Task edit_blog(string blogId, string title = null, string content = null, List<byte[]> imageList = null, bool fansOnly = false, string backgroundColor = null)
252+
public Task edit_blog(string blogId, string title = null, string content = null, IEnumerable<byte[]> imageList = null, bool fansOnly = false, string backgroundColor = null)
253253
{
254254
JArray mediaList = new JArray();
255255
JObject extensionData = new JObject();

0 commit comments

Comments
 (0)