1
HttpWebRequest.BeginGetResponse
을 사용하고 POST 메서드 업로드를 위해 진행률 변경 이벤트를받을 수 있습니까?HttpWebRequest & UploadProgressChanged?
내가 지금 가지고있는 코드의 일부는 다음과 같습니다
HttpWebRequest req = (HttpWebRequest)WebRequestCreator.ClientHttp.Create(uploadUri);
req.Method = "POST";
req.ContentType = "multipart/form-data; boundary=" + boundary + "";
req.ContentLength = dataBuffer.Length;
req.AllowReadStreamBuffering = false;
req.AllowWriteStreamBuffering = false;
DispatcherHelper.CheckBeginInvokeOnUI(() =>
{
ProgressText = "Waiting for request stream...";
});
req.BeginGetRequestStream(new AsyncCallback(GotRequestStreamForUpload), new SendPhotoAsyncState(req, dataBuffer, photo));
BeginGetResponse를 호출 :
request.BeginGetResponse(new AsyncCallback(GotResponseStreamForUpload), new SendPhotoAsyncState(request, null, flickRPhoto));
내가 스트림에 변경 통지 할 요청을 알 수있는 방법 ? 내가 사진을 업로드의 진행에 따라 UI를 업데이트 할 수 있도록하려는
...다음 코드는 웹 클라이언트와 함께 작동하지 않습니다이 실버 라이트
WebClient wc = new WebClient();
wc.UploadStringCompleted += (s, e) =>
{
// What photo is this ?
FlickRUploadPhoto fup = ((SendPhotoAsyncState)e.UserState).FlickrPhoto2Upload;
DispatcherHelper.CheckBeginInvokeOnUI(() =>
{
fup.tCompleted = DateTime.Now;
FileUploadComplete(this, new FlickRUploadCompleteEventArgs(fup));
});
};
wc.UploadProgressChanged += (s2,e2) =>
{
// Was there an error ?
// What photo is this ?
FlickRUploadPhoto fup = ((SendPhotoAsyncState)e2.UserState).FlickrPhoto2Upload;
DispatcherHelper.CheckBeginInvokeOnUI(() =>
{
fup.ProgressPercentage = e2.ProgressPercentage;
fup.ProgressPercentageString = e2.ProgressPercentage.ToString() + "%";
fup.BytesUploaded = e2.BytesSent;
});
};
string data = dataBuffer.ToString();
wc.UploadStringAsync(uploadUri, "POST", data , new SendPhotoAsyncState(null, dataBuffer, photo));
입니다 .. 그래서 나는 UploadStringAsync를 사용해야한다. ??
나는 아래에 있었다를 당신이 webclient와 contenttype 및 헤더 등을 조작 할 수 없다는 인상? –