Пример #1
0
        /// <summary>
        /// 发送文件
        /// </summary>
        /// <param name="Fe">文件类型</param>
        /// <param name="FileData">文件byte</param>

        public static void SendFile(FileEntity Fe, byte[] FileData)
        {
            Fe.BaseRequest = new BaseRequestEntity()
            {
                DeviceID = MethodsHelper.GetDeviceId(), Uin = CommonDefine.LoginResult.wxuin, Sid = CommonDefine.LoginResult.wxsid, Skey = CommonDefine.LoginResult.skey
            };
            string Boundary = "------WebKitFormBoundaryUOlSZtOip6JP4NSr";

            HttpMethods.AddContent("id", "WU_FILE_0", Boundary);
            HttpMethods.AddContent("name", Fe.FileName, Boundary);
            HttpMethods.AddContent("type", Fe.FileType, Boundary);
            HttpMethods.AddContent("lastModifiedDate", Fe.FileModiftTime.ToLocalTime().ToString(), Boundary);
            HttpMethods.AddContent("size", Fe.DataLen.ToString(), Boundary);
            HttpMethods.AddContent("mediatype", Fe.Mediatype1, Boundary);
            HttpMethods.AddContent("uploadmediarequest", JsonConvert.SerializeObject(Fe), Boundary);
            HttpMethods.AddContent("webwx_data_ticket", CommonDefine.GetCookieDictionary == null ? "" : CommonDefine.GetCookieDictionary["webwx_data_ticket"], Boundary); //"gScOa2YvEEtszEvhoxdwXCeg"
            HttpMethods.AddContent("pass_ticket", CommonDefine.LoginResult.pass_ticket, Boundary);                                                                        //"ekYYf2P7xOH5iI+oYrf/GiGrZhE+fUEGMiXe3Pq71rb4MDe+7ICbD+kglD4ZE+Ey"
            HttpMethods.AddContent("filename", Fe.FileName, Fe.FileType, FileData, Boundary);
            HttpMethods.OptionsDataMulitData(UrlDefine.SendFileUrl, CommonDefine.Cookies, Encoding.UTF8, Boundary);
            HttpMethods.PostDataMulitData(UrlDefine.SendFileUrl, CommonDefine.Cookies, Encoding.UTF8, Boundary);
        }