如何下载平台附件?
1、氚云接口地址
https://www.h3yun.com/Api/DownloadBizObjectFile
2、接口说明:
1)、认证方式:在服务Soap:Header中传入以下参数
Secret | String | |
EngineCode | String | 企业引擎Code |
2)输入参数:
attachmentId | String | 附件Id |
EngineCode | String | 企业引擎Code |
3、接口调用示例(C#)
public static void GetFile(string fileId) { HttpClient client = new HttpClient();
Dictionary<string, string> keyValues = new Dictionary<string, string>(); keyValues.Add("attachmentId", fileId); keyValues.Add("EngineCode", "p6a24eero"); FormUrlEncodedContent content = new FormUrlEncodedContent(keyValues); content.Headers.Add("EngineCode", "p6a24eero4"); content.Headers.Add("EngineSecret", "tGNDNn0PdqyvEqb6EfIBACdvoUg==");
HttpResponseMessage result = client.PostAsync("https://www.h3yun.com/Api/DownloadBizObjectFile", content).Result; Stream responseStream = result.Content.ReadAsStreamAsync().Result;
var header = result.Content.Headers.GetValues("Content-Disposition");///附件名称 Console.WriteLine(header);
Stream stream = new FileStream("1.png", FileMode.Create); byte[] bArr = new byte[1024]; int size = responseStream.Read(bArr, 0, bArr.Length); while (size > 0) { stream.Write(bArr, 0, size); size = responseStream.Read(bArr, 0, bArr.Length); }
stream.Close(); responseStream.Close();
Console.ReadLine(); } |