2013-05-16 1 views
0

메트로 앱의 백그라운드 전송 (업 로더) 진행률은 다음과 같이 1 초 이내에 1MB보다 큰 파일에 대해 100 %를 제공합니다.메트로 앱의 백그라운드 전송 (업 로더) 진행 문제

*Running: c5593753-d155-425a-8e25-6b1f90bbff85 
Progress: c5593753-d155-425a-8e25-6b1f90bbff85, Status: Running 
- Sent bytes: 131072 of 1310245 (10%), Received bytes: 0 of 0 
Progress: c5593753-d155-425a-8e25-6b1f90bbff85, Status: Running 
- Sent bytes: 1310245 of 1310245 (100%), Received bytes: 0 of 0* 

따라서 언젠가 업로드가 완료된 후 내 진행률 표시 줄도, wrong.Now의 코스 100 %를 보여주고 난 다음 얻을 :

*Progress: c5593753-d155-425a-8e25-6b1f90bbff85, Status: Completed 
- Sent bytes: 1310245 of 1310245 (100%), Received bytes: 49 of 49 
Completed: c5593753-d155-425a-8e25-6b1f90bbff85, Status Code: 200 
- Response updated; Header count: 9* 

그래서 어떤 의미에서 업 로더가 작동 하지만 다시이 잘못된 원인은 파일을 100 %, actual.I 완료하지 않은 10 MB의 파일을 테스트하고있다 고소는 여전히 동일합니다. 100 % 진행 상태와 "완료 됨"상태는 3 분이 경과 한 후에 만 ​​발생합니다.

동일한 업로드 샘플 인 http://code.msdn.microsoft.com/windowsapps/Background-Transfer-Sample-d7833f61을 사용하고 있습니다. 다음과 같이 내가 사용하고있다

코드는 다음과 같습니다

private async void StartUpload_Click(object sender, RoutedEventArgs e) 
    { 

     if (ApplicationView.Value == ApplicationViewState.Snapped && !ApplicationView.TryUnsnap()) 
     { 
      rootPage.NotifyUser("File picker cannot be opened in snapped mode. Please unsnap first.", NotifyType.ErrorMessage); 
      return; 
     } 

     FileOpenPicker picker = new FileOpenPicker(); 
     picker.FileTypeFilter.Add("*"); 
     StorageFile file = await picker.PickSingleFileAsync(); 

     Uri uri; 


     string uploadFileURl = "https://dummy.com/Link1/Link2"; 


     if (!Uri.TryCreate(uploadFileURl, UriKind.RelativeOrAbsolute, out uri)) 
     { 
      rootPage.NotifyUser("Invalid URI.", NotifyType.ErrorMessage); 
      return; 
     } 

     if (file == null) 
     { 
      rootPage.NotifyUser("No file selected.", NotifyType.ErrorMessage); 
      return; 
     } 

     BackgroundUploader uploader = new BackgroundUploader(); 

     uploader.Method = "POST"; 
     uploader.SetRequestHeader("uid", "[email protected]"); 
     uploader.SetRequestHeader("pwd","test"); 



     uploader.SetRequestHeader("file_name", file.Name); 
     uploader.SetRequestHeader("p", "/"); 

     //just hard coding the particular file size for sample here 
     Int64 size = 221390; 
     uploader.SetRequestHeader("file_size", size.ToString()); 


     UploadOperation upload = uploader.CreateUpload(uri, file); 



     // Attach progress and completion handlers. 
     await HandleUploadAsync(upload, true); 
    } 

    private async Task HandleUploadAsync(UploadOperation upload, bool start) 
    { 

     try 
     { 
      LogStatus("Running: " + upload.Guid, NotifyType.StatusMessage); 

      Progress<UploadOperation> progressCallback = new Progress<UploadOperation>(UploadProgress); 
      if (start) 
      { 

       // Start the upload and attach a progress handler. 
       await upload.StartAsync().AsTask(cts.Token,progressCallback); 
      } 
      else 
      { 
       // The upload was already running when the application started, re-attach the progress handler. 
       await upload.AttachAsync().AsTask(cts.Token, progressCallback); 
      } 

      ResponseInformation response = upload.GetResponseInformation(); 

      LogStatus(String.Format("Completed: {0}, Status Code: {1}", upload.Guid, response.StatusCode), 
       NotifyType.StatusMessage); 
     } 
     catch (TaskCanceledException) 
     { 
      LogStatus("Canceled: " + upload.Guid, NotifyType.StatusMessage); 
     } 
     catch (Exception ex) 
     { 

       throw; 

     } 
    } 

    private void UploadProgress(UploadOperation upload) 
    { 
     MarshalLog(String.Format("Progress: {0}, Status: {1}", upload.Guid, upload.Progress.Status)); 

     BackgroundUploadProgress progress = upload.Progress; 

     double percentSent = 100; 
     if (progress.TotalBytesToSend > 0) 
     { 
      percentSent = progress.BytesSent * 100/progress.TotalBytesToSend; 
     } 

     //MarshalLog(String.Format(" - Sent bytes: {0} of {1} ({2}%)", 
     // progress.BytesSent, progress.TotalBytesToSend, percentSent)); 

     MarshalLog(String.Format(" - Sent bytes: {0} of {1} ({2}%), Received bytes: {3} of {4}", 
      progress.BytesSent, progress.TotalBytesToSend, percentSent, 
      progress.BytesReceived, progress.TotalBytesToReceive)); 

     if (progress.HasRestarted) 
     { 
      MarshalLog(" - Upload restarted"); 
     } 

     if (progress.HasResponseChanged) 
     { 
      // We've received new response headers from the server. 
      MarshalLog(" - Response updated; Header count: " + upload.GetResponseInformation().Headers.Count); 

      // If you want to stream the response data this is a good time to start. 
      // upload.GetResultStreamAt(0); 
     } 
    } 

답변

0

나는 문제가 이제 해결 믿습니다. 그것의 간단한 DNS 설정 문제.

시스템 프록시 뒤에있는 경우

  1. 이동 gpedit.msc를 위해 - 컴퓨터 구성에서> -> 관리 템플릿 -> 네트워크 -> 네트워크 격리.
  2. "IPaddress : Port"구문을 사용하여 앱용 인터넷 프록시 서버를 사용하도록 설정해야합니다. 시스템 프록시 뒤에 있지 않은 경우 netsh winhttp import proxy source=ie

:

시스템 설정에서 DNS 서버 설정이 적절한 지 확인하십시오

  • 명령 줄을 실행합니다. 의미, Preferred & 보조 DNS 서버 실제 DNS 서버 주소를 제공해야하며 프록시 서버 주소는 제공해야합니다.