请求方式:POST(HTTPS)
请求地址:https://www.h3yun.com/Api/DownloadBizObjectFile
参数说明:
参数 | 参数类型 | 必须 | 说明 |
attachmentId | String | 是 | 附件id |
EngineCode | String | 是 | 企业引擎 |
请求示例(C#):
GetFile("fa5a96d4-559c-46c0-9dcc-dcb6e427a94c");//调用下载附件方法,传递参数:附件id
public static void GetFile(string fileId) { HttpClient client = new HttpClient();
//form-data:attachmentId、EngineCode Dictionary<string, string> keyValues = new Dictionary<string, string>(); keyValues.Add("attachmentId", fileId); keyValues.Add("EngineCode", ""); //身份认证参数 FormUrlEncodedContent content = new FormUrlEncodedContent(keyValues); content.Headers.Add("EngineCode", ""); content.Headers.Add("EngineSecret", ""); //请求执行 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");//附件名称 string[] dd = header.ToArray(); Console.WriteLine(header); //创建本地文件 Stream stream = new FileStream(dd[0], 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(); FileStream ddd = new FileStream(dd[0], FileMode.Open); var fd = ddd.Length; byte[] bytes = new byte[fd];
ddd.Read(bytes, 0, Convert.ToInt32(fd)); ddd.Close(); responseStream.Close(); } |
文章反馈
*请选择您遇到的问题类型?
*请描述问题详情
支持上传9张图片且单张大小不超过3M