本文整理汇总了C#中HttpRequest.AddFile方法的典型用法代码示例。如果您正苦于以下问题:C# HttpRequest.AddFile方法的具体用法?C# HttpRequest.AddFile怎么用?C# HttpRequest.AddFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpRequest
的用法示例。
在下文中一共展示了HttpRequest.AddFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: docs_save
public static dynamic docs_save(string path_file, string name_doc = "Unknown", string v = "5.21")
{
Dictionary<string, dynamic> result;
string error = "";
var request = new HttpRequest();
request.AddUrlParam("access_token", Settings1.Default.token);
request.AddUrlParam("v", v);
try
{
string content = request.Get(uri_api + "docs.getUploadServer").ToString();
result = JsonConvert.DeserializeObject<Dictionary<string, dynamic>>(content);
string url_upload = result["response"]["upload_url"];
request = new HttpRequest();
request.AddFile("file", path_file);
content = request.Post(url_upload).ToString();
result = JsonConvert.DeserializeObject<Dictionary<string, dynamic>>(content);
request = new HttpRequest();
request.AddUrlParam("file", result["file"]);
request.AddUrlParam("title", name_doc.Replace(".jpg", ""));
request.AddUrlParam("access_token", Settings1.Default.token);
request.AddUrlParam("v", v);
content = request.Get(uri_api + "docs.save").ToString();
result = JsonConvert.DeserializeObject<Dictionary<string, dynamic>>(content);
string result_string = "doc" + result["response"][0]["owner_id"] + "_" + result["response"][0]["id"];
return result_string;
}
catch (Exception ex)
{
MessageBox.Show(error = ex.Message + " " + ex.InnerException);
return null;
}
}