Skip to content

Commit

Permalink
Merge pull request #6 from adrenaline96/master
Browse files Browse the repository at this point in the history
Version 2.2
  • Loading branch information
adrenaline96 committed Sep 26, 2019
2 parents 215dfbd + ceedab2 commit 7e90516
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions MSClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ public string DownloadFile(string hash)

}

public string UrlToCollection(string urlToUpload)
public string UrlToCollection(string urlToUpload, bool enableCrawling = false)
{
string url = $@"https://malshare.com/api.php?api_key={key}&action=download_url";

Expand All @@ -300,7 +300,10 @@ public string UrlToCollection(string urlToUpload)
{
NameValueCollection data = new NameValueCollection();
data["url"] = urlToUpload;

if(enableCrawling == true)
{
data["recursive"] = "1";
}

var response = wb.UploadValues(url, "POST", data);
string responseInString = Encoding.UTF8.GetString(response);
Expand All @@ -315,10 +318,17 @@ public string UrlToCollection(string urlToUpload)
{
if (ex.Response != null)
{
var response = ex.Response;
var dataStream = response.GetResponseStream();
var reader = new StreamReader(dataStream);
var details = reader.ReadToEnd();
WebResponse response = ex.Response;
Stream dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
string details = reader.ReadToEnd();

if (details.Contains("error"))
{
dynamic dynObj = JsonConvert.DeserializeObject(details);

return $"Error for API key {key}: {dynObj.error}";
}

return details;
}
Expand Down
Binary file not shown.
Binary file modified MalShare.NET.dll
Binary file not shown.

0 comments on commit 7e90516

Please sign in to comment.