Beispiel #1
0
 public HyvesUploadRequest(string filePath)
 {
     this.filePath = filePath;
     this.mediaToken = new MediaToken();
     this.mediaToken.HyvesUploadRequest = this;
 }
Beispiel #2
0
 private void UploadFileRequest(string filePath, MediaToken mediaToken)
 {
     // Initializing request
     string uploadUrl = string.Format("http://{0}/upload?token={1}&name={2}", mediaToken.ip, mediaToken.token, Path.GetFileName(filePath));
     this.httpWebRequest = (HttpWebRequest)WebRequest.Create(uploadUrl);
     this.httpWebRequest.Method = "POST";
     httpWebRequest.ContentType = "application/octet-stream";
     httpWebRequest.BeginGetRequestStream(new AsyncCallback(GetRequestStreamCallback), new RequestCallbackDelegate<string>(UploadFileRequestCallback));
 }
Beispiel #3
0
 private void UploadStatusRequest(MediaToken mediaToken)
 {
     // Initializing request
     string uploadUrl = string.Format("http://{0}/status?token={1}", mediaToken.ip, mediaToken.token);
     this.httpWebRequest = (HttpWebRequest)WebRequest.Create(uploadUrl);
     this.httpWebRequest.Method = "GET";
     httpWebRequest.ContentType = "application/x-www-form-urlencoded";
     httpWebRequest.BeginGetResponse(new AsyncCallback(GetResponseCallback), new RequestCallbackDelegate<string>(UploadFileStatusRequestCallback));
 }
Beispiel #4
0
 private void MediaTokenCallback(ServiceResult<MediaToken> serviceResult)
 {
     if (serviceResult.IsError)
     {
         // calling consumer as error occurred
         serviceResult.Result = this.mediaToken;
         this.ServiceResult = serviceResult;
         this.serviceCallback(serviceResult);
         return;
     }
     // Uploading file
     this.mediaToken = serviceResult.Result;
     this.mediaToken.HyvesUploadRequest = this;
     UploadFileRequest(this.filePath, mediaToken);
 }