Ejemplo n.º 1
0
 public void UploadVoiceMessageDocument(Stream stream, List <int> waveform, Action <BackendResult <Doc, ResultCode> > callback, Action <double> progressCallback = null, Cancellation cancellation = null)
 {
     DocumentsService.GetDocumentUploadServer(0, "audio_message", (Action <BackendResult <VKClient.Audio.Base.UploadServerAddress, ResultCode> >)(uploadUrlResponse =>
     {
         if (uploadUrlResponse.ResultCode == ResultCode.Succeeded)
         {
             JsonWebRequest.UploadVoiceMessage(uploadUrlResponse.ResultData.upload_url, stream, "file", "file", waveform, (Action <JsonResponseData>)(jsonResult =>
             {
                 if (jsonResult.IsSucceeded)
                 {
                     UploadDocResponseData uploadData = JsonConvert.DeserializeObject <UploadDocResponseData>(jsonResult.JsonString);
                     if (string.IsNullOrEmpty(uploadData.error))
                     {
                         DocumentsService.SaveDocument(uploadData, callback);
                     }
                     else
                     {
                         callback(new BackendResult <Doc, ResultCode>(ResultCode.UnknownError));
                     }
                 }
                 else
                 {
                     callback(new BackendResult <Doc, ResultCode>(ResultCode.UnknownError));
                 }
             }), "Voice Message", progressCallback, cancellation);
         }
         else
         {
             callback(new BackendResult <Doc, ResultCode>(uploadUrlResponse.ResultCode));
         }
     }));
 }