private void GenerateFileUploadUrl(Dictionary <string, object> externalQueryParam, PNCallback <PNGenerateFileUploadUrlResult> callback)
        {
            RequestState <PNGenerateFileUploadUrlResult> requestState = new RequestState <PNGenerateFileUploadUrlResult>();

            requestState.ResponseType      = PNOperationType.PNGenerateFileUploadUrlOperation;
            requestState.PubnubCallback    = callback;
            requestState.Reconnect         = false;
            requestState.EndPointOperation = this;

            requestState.UsePostMethod = true;

            Dictionary <string, object> messageEnvelope = new Dictionary <string, object>();

            if (!string.IsNullOrEmpty(sendFileName))
            {
                messageEnvelope.Add("name", sendFileName);
            }
            string postMessage = jsonLibrary.SerializeToJsonString(messageEnvelope);

            byte[] postData = Encoding.UTF8.GetBytes(postMessage);

            IUrlRequestBuilder urlBuilder = new UrlRequestBuilder(config, jsonLibrary, unit, pubnubLog, pubnubTelemetryMgr, (PubnubInstance != null) ? PubnubInstance.InstanceId : "");
            Uri request = urlBuilder.BuildGenerateFileUploadUrlRequest("POST", postMessage, this.channelName, externalQueryParam);

            UrlProcessRequest(request, requestState, false, postData).ContinueWith(r =>
            {
                string json = r.Result.Item1;
                if (!string.IsNullOrEmpty(json))
                {
                    List <object> result = ProcessJsonResponse(requestState, json);
                    ProcessResponseCallbacks(result, requestState);
                }
            }, TaskContinuationOptions.ExecuteSynchronously).Wait();
        }
        private async Task <PNResult <PNGenerateFileUploadUrlResult> > GenerateFileUploadUrl(Dictionary <string, object> externalQueryParam)
        {
            PNResult <PNGenerateFileUploadUrlResult> ret = new PNResult <PNGenerateFileUploadUrlResult>();

            if (string.IsNullOrEmpty(sendFileName))
            {
                PNStatus errStatus = new PNStatus {
                    Error = true, ErrorData = new PNErrorData("Invalid file name", new ArgumentException("Invalid file name"))
                };
                ret.Status = errStatus;
                return(ret);
            }

            RequestState <PNGenerateFileUploadUrlResult> requestState = new RequestState <PNGenerateFileUploadUrlResult>();

            requestState.ResponseType      = PNOperationType.PNGenerateFileUploadUrlOperation;
            requestState.Reconnect         = false;
            requestState.EndPointOperation = this;

            requestState.UsePostMethod = true;

            Dictionary <string, object> messageEnvelope = new Dictionary <string, object>();

            if (!string.IsNullOrEmpty(sendFileName))
            {
                messageEnvelope.Add("name", sendFileName);
            }
            string postMessage = jsonLibrary.SerializeToJsonString(messageEnvelope);

            byte[] postData = Encoding.UTF8.GetBytes(postMessage);

            IUrlRequestBuilder urlBuilder = new UrlRequestBuilder(config, jsonLibrary, unit, pubnubLog, pubnubTelemetryMgr, (PubnubInstance != null) ? PubnubInstance.InstanceId : "");
            Uri request = urlBuilder.BuildGenerateFileUploadUrlRequest("POST", postMessage, this.channelName, externalQueryParam);

            Tuple <string, PNStatus> JsonAndStatusTuple = await UrlProcessRequest(request, requestState, false, postData).ConfigureAwait(false);

            ret.Status = JsonAndStatusTuple.Item2;
            string json = JsonAndStatusTuple.Item1;

            if (!string.IsNullOrEmpty(json))
            {
                List <object>   resultList      = ProcessJsonResponse(requestState, json);
                ResponseBuilder responseBuilder = new ResponseBuilder(config, jsonLibrary, pubnubLog);
                PNGenerateFileUploadUrlResult responseResult = responseBuilder.JsonToObject <PNGenerateFileUploadUrlResult>(resultList, true);
                if (responseResult != null)
                {
                    ret.Result = responseResult;
                }
            }

            return(ret);
        }