3

これはモノタッチ アプリケーションです。この例外でフィールドにエラーが表示されます。他のSOの質問が表示されますが、私の問題を解決しているようには見えません。これは、サーバーの maxRequestLength または executionTimeout に関連している可能性がありますか? 私は本当にアイデアがありません...

私は WebRequest を使用していません。WebClient を使用しています。助けてください!

スタックトレース

System.Net.WebException: Error getting response stream (ReadDone1): ReceiveFailure
  at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0 
  at System.Net.HttpWebRequest.GetResponse () [0x00000] in <filename unknown>:0 
  at System.Net.WebClient.GetWebResponse (System.Net.WebRequest request) [0x00000] in <filename unknown>:0 
  at System.Net.WebClient.ReadAll (System.Net.WebRequest request, System.Object userToken) [0x00000] in <filename unknown>:0 
  at System.Net.WebClient.UploadFileCore (System.Uri address, System.String method, System.String fileName, System.Object userToken) [0x00000] in <filename unknown>:0 
  at System.Net.WebClient.UploadFile (System.Uri address, System.String method, System.String fileName) [0x00000] in <filename unknown>:0 

クライアントコード (モノタッチ)

    public void UploadVideo(Guid organizationId, string path) {
        WebClient wc = new WebClient();
        var token = Convert.ToBase64String(Encoding.UTF8.GetBytes(string.Format("{0}:{1}", username, password)));
        var authHeader = string.Format("Basic {0}", token);
        wc.Headers.Add("Authorization", authHeader);
        var resource = string.Format("/organizations/{0}/SyncVideo/", organizationId);

        var fi = new FileInfo(path);            
        wc.UploadFile(restClient.BaseUrl + resource, "POST", path);
        wc.Dispose();            
    }

サーバー コード (ASP.Net MVC3)

[HttpPost, Url("v3/organizations/{organizationId?}/SyncVideo/")]
public virtual JsonResult SyncVideo(HttpPostedFileBase file, Guid? organizationId) {
    if (organizationId.IsNull()) throw new HttpNotFoundExecption();
    if (organizationId != RESTContext.OrganizationId) throw new HttpNotAuthorizedException();

    var basePath = RESTContext.Config.VideoPath;

    using (new Impersonator(RESTContext.Config.VideoPathUsername, RESTContext.Config.VideoPathDomain,
        RESTContext.Config.VideoPathPassword)) {
        if (!Directory.Exists(basePath))
            Directory.CreateDirectory(basePath);
        file.SaveAs(basePath + @"\" + file.FileName);
    }
    return JsonSuccess();
}
4

0 に答える 0