public byte[] GenerateMultipartContent(string url, HttpMethod httpMethod, IMultipartRequestConfiguration multipartRequestConfiguration, IEnumerable <IMultipartElement> multipartElements)
        {
            var urlParameters = _webHelper.GetURLParameters(url);

            var multipartContent = new StringBuilder();

            foreach (var urlParameter in urlParameters)
            {
                if (urlParameter.Value != null)
                {
                    var    notEncodedParameterValue = _twitterStringFormatter.TwitterDecode(urlParameter.Value);
                    byte[] parameterBytes           = Encoding.UTF8.GetBytes(notEncodedParameterValue);
                    string encodedParameter         = multipartRequestConfiguration.EncodingAlgorithm.GetString(parameterBytes, 0, parameterBytes.Length);

                    multipartContent.AppendFormat("--{0}\r\nContent-Disposition: form-data; name=\"{1}\"\r\n\r\n{2}\r\n",
                                                  multipartRequestConfiguration.Boundary, urlParameter.Key, encodedParameter);
                }
            }

            foreach (var multiPartElement in multipartElements)
            {
                multipartContent.Append(multiPartElement);
            }

            multipartContent.Append(multipartRequestConfiguration.EndBoundary);
            return(multipartRequestConfiguration.EncodingAlgorithm.GetBytes(multipartContent.ToString()));
        }
        private IMultipartElement GenerateMultipartElement(IMedia media, string contentId, IMultipartRequestConfiguration configuration)
        {
            var additionalParameters = new Dictionary<string, string>();

            var element = new MultipartElement
            {
                Boundary = configuration.Boundary,
                ContentId = contentId,
                ContentDispositionType = "form-data",
                ContentType = "application/octet-stream",
                AdditionalParameters = additionalParameters,
                Data = configuration.EncodingAlgorithm.GetString(media.Data, 0, media.Data.Length),
            };

            return element;
        }
        private IMultipartElement GenerateMultipartElement(IMedia media, IMultipartRequestConfiguration configuration)
        {
            var additionalParameters = new Dictionary <string, string>();
            // additionalParameters.Add("filename", media.FileName);

            var element = new MultipartElement
            {
                Boundary  = configuration.Boundary,
                ContentId = "media[]",
                ContentDispositionType = "form-data",
                ContentType            = "application/octet-stream",
                AdditionalParameters   = additionalParameters,
                Data = configuration.EncodingAlgorithm.GetString(media.Data, 0, media.Data.Length),
            };

            return(element);
        }
        public byte[] GenerateMultipartContent(string url, HttpMethod httpMethod, IMultipartRequestConfiguration multipartRequestConfiguration, IEnumerable<IMultipartElement> multipartElements)
        {
            var urlParameters = _webHelper.GetURLParameters(url);

            var multipartContent = new StringBuilder();
            foreach (var urlParameter in urlParameters)
            {
                if (urlParameter.Value != null)
                {
                    var notEncodedParameterValue = _twitterStringFormatter.TwitterDecode(urlParameter.Value);
                    byte[] parameterBytes = Encoding.UTF8.GetBytes(notEncodedParameterValue);
                    string encodedParameter = multipartRequestConfiguration.EncodingAlgorithm.GetString(parameterBytes, 0, parameterBytes.Length);

                    multipartContent.AppendFormat("--{0}\r\nContent-Disposition: form-data; name=\"{1}\"\r\n\r\n{2}\r\n",
                        multipartRequestConfiguration.Boundary, urlParameter.Key, encodedParameter);
                }
            }

            foreach (var multiPartElement in multipartElements)
            {
                multipartContent.Append(multiPartElement);
            }

            multipartContent.Append(multipartRequestConfiguration.EndBoundary);
            return multipartRequestConfiguration.EncodingAlgorithm.GetBytes(multipartContent.ToString());
        }