gamepdc_个人页

个人头像照片 gamepdc
0
2
0

个人介绍

暂无个人介绍

擅长的技术

获得更多能力
通用技术能力:

暂时未有相关通用技术能力~

云产品技术能力:

暂时未有相关云产品技术能力~

阿里云技能认证

详细说明
暂无更多信息
正在加载, 请稍后...
暂无更多信息
  • 回答了问题 2016-05-31

    OSS上传文件400错误,提示MalformedPOSTRequest

    ReOSS上传文件400错误,提示MalformedPOSTRequest Unity3D模仿WWW实现的兼容OSS的Multipart上传类 public class MultiPartUpload {     public bool isDone;     public bool isSuccess;     public string rspString;     private HttpWebRequest request;     private HttpWebResponse response;     private Stream streamResponse;     private string mUrl;     private Dictionary mKeyValues;     private string mFileName;     private byte[] mFileData;     private byte[] mPostData;     private string mBoundary;     private IAsyncResult mResult;     public MultiPartUpload(string url, Dictionary keyValues, string filename, byte[] data)     {         streamResponse = null;         isDone = false;         isSuccess = false;         rspString = '';         mUrl = url;         mKeyValues = keyValues;         mFileName = filename;         mFileData = data;         mBoundary = '--------9431149156168';         HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);         webRequest.Timeout = -1;         webRequest.Method = 'POST';         webRequest.ContentType = 'multipart/form-data; boundary=' + mBoundary;         this.request = webRequest;         mResult = webRequest.BeginGetRequestStream(getRequestStreamCallback, this);     }     private void getRequestStreamCallback(IAsyncResult ar)     {         try         {             Stream postStream = request.EndGetRequestStream(ar);             string boundary = mBoundary;                          string requestBody = '--' + boundary + '\r\n';             foreach(KeyValuePair keyValue in mKeyValues)             {                 string postField = 'Content-Disposition: form-data; name=\'' + keyValue.Key + '\'\r\n'                     + '\r\n' + keyValue.Value + '\r\n'                     + '--' + boundary + '\r\n';                 requestBody += postField;             }             string tail = '\r\n' + '--' + boundary + '--\r\n';             List postData = new List();             {                 postData.AddRange(System.Text.Encoding.Default.GetBytes(requestBody));                 string fileString = 'Content-Disposition: form-data; name=\'file\'; filename=\'' + mFileName + '\'\r\n\r\n';                 postData.AddRange(System.Text.Encoding.Default.GetBytes(fileString));                 postData.AddRange(mFileData);                 postData.AddRange(System.Text.Encoding.Default.GetBytes(tail));             }             mPostData = postData.ToArray();             postStream.Write(mPostData, 0, mPostData.Length);             postStream.Close();             mResult = (IAsyncResult)request.BeginGetResponse(new AsyncCallback(getResponseCallback), this);         }         catch (Exception e)         {             rspString = e.Message;             isDone = true;         }     }     private void getResponseCallback(IAsyncResult ar)     {         try         {             HttpWebResponse rsp = (HttpWebResponse)request.EndGetResponse(ar);             Stream streamRsp = rsp.GetResponseStream();             StreamReader streamRead = new StreamReader(streamRsp);             rspString = streamRead.ReadToEnd();             isSuccess = rsp.StatusCode == HttpStatusCode.OK;             isDone = true;             streamRsp.Close();             streamRead.Close();             rsp.Close();         }         catch (Exception e)         {             rspString = e.Message;             isDone = true;         }     } }
    踩0 评论0
  • 提交了问题 2016-05-30

    OSS上传文件400错误,提示MalformedPOSTRequest

正在加载, 请稍后...
滑动查看更多
正在加载, 请稍后...
暂无更多信息