I'm developing Windows phone(8.0)apps and I'm new to it,I'm using below code to post image to server in Base64 format using post client
Uri uri = new Uri(UPLOAD_IMAGE_PATH);
UploadImageData requestData = new UploadImageData();
requestData.image = base64String;
string jsonString = JsonConvert.SerializeObject(requestData);
PostClient proxy = new PostClient(jsonString);
proxy.DownloadStringCompleted += new PostClient.DownloadStringCompletedHandler(proxy_DownloadStringCompleted);
proxy.DownloadStringAsync(uri);
where base64String is my image string encoded in Bae64 by using below code
internal static string ImageToBase64String(Stream choosenPhoto,Image image)
{
WriteableBitmap bmp = new WriteableBitmap((BitmapSource)image.Source);
byte[] byteArray;
using (MemoryStream stream = new MemoryStream())
{
bmp.SaveJpeg(stream, bmp.PixelWidth, bmp.PixelHeight, 0, 100);
byteArray = stream.ToArray();
return Convert.ToBase64String(byteArray);
}
}
In below response it returns "disallowed key charaters" on result.
void proxy_DownloadStringCompleted(object sender, WindowsPhonePostClient.DownloadStringCompletedEventArgs e)
{
string result = e.Result;
}
But when i post same JSON string using REST Client from Mozilla, JSON response from server is successfull.
I searched about this and i got some links link 1, link 2 that i need to allow characters on server side in Input.php file, So exactly what kind of character i need to allow. It works from REST Client did i miss something in my C# code, Please help me
It doesn't seem to explicitly mention the Base64 string (unless I'm missing something, having never developed for a WinPhone OS). Have you checked the URL that you're sending a POST request to?
Related
I am trying to convert svg image URL to base 64, the problem is that i am limited and I can't use third party libraries in this project.
Is there any possible way to do that?
I've tried this but it did not work. Someone said that svg is a file not an image so DownloadData won't work right.
byte[] imageBytes;
string base64String = string.Empty;
using (WebClient wc = new WebClient())
{
imageBytes = wc.DownloadData(appSuggestion?.IconUri.AbsoluteUri);
base64String = Convert.ToBase64String(imageBytes);
}
Any Idea what can I do?
Edit:
I wanted to use it in a data url "data:image/svg+xml;base64,[base64String]" in adaptive cards as an image url, at first I thought that adaptive cards are not supporting svg, but then I tried to write the url on chrome and it also didn't show the image.
Using DownloadData is perfectly valid here as it will return the content of the URI returned by the server as byte[]. The base64 conversion is also correct. What you've got so far will give you the base64-encoded content of any URI. I've just tested this and it works correctly.
Here's my test code to produce a data: URI from an SVG file hosted on a remote web server:
public string SVGUriToDataUri(Uri src)
{
using (var wc = new System.Net.WebClient())
{
var imageBytes = wc.DownloadData(src);
var imageBase64 = Convert.ToBase64String(imageBytes);
return "data:image/svg+xml;base64," + {imageBase64};
}
}
Putting the output of that into the address bar in Chrome displays the image as expected.
Here's a more general version that gets the mime type from the server:
public string DownloadAsDataUri(Uri src)
{
using (var wc = new System.Net.WebClient())
{
var imageBytes = wc.DownloadData(src);
var imageBase64 = Convert.ToBase64String(imageBytes);
var mimeType = wc.ResponseHeaders["content-type"];
if (mimeType.Contains(';'))
mimeType = mimeType.Split(';')[0];
return $"data:{mimeType};base64,{imageBase64}";
}
}
If it's a PNG, BMP, ICO or whatever and it works when you put the URI itself then this should work. It works for me with the image link you posted - which is SVG.
If this does not work for then please post a copy of the output so we can investigate. At this point the only other option I can think of is that appSuggestion?.IconUri.AbsoluteUri is not giving you the correct address.
I am trying to download a file which has hebrew characters in the name
https://example.com/path/צילום מסך 2014.04.16 ב.16.44.30.png
When I try to download with the browser, the filename is correctly encoded and the server returns the file.
If I am downloading with C# code from the server, the filename is not encoded properly thus the server returns error 403.
If I encode the filename using HttpUtility.UrlEncode() and pass it to the WebRequest class, it is encoded properly but it has the same result (error 403).
I inspected the web calls with Fiddler and the encoded filename is different than what browser is encoding. If I get the filename and decode it, the filename is different (see below)
https://example.com/path/צילום מסך 2014.04.16 ב.16.44.30.png
I suspect that the problem is that the filename is partially encoded with Right-To-Left characters and the WebRequest class isn't equipped with the methods to handle it.
please see below the code used to download all of the files.
private byte[] GetFile(string url)
{
byte[] result;
byte[] buffer = new byte[4096];
WebRequest request = WebRequest.CreateHttp(url);
using (var remoteStream = request.GetResponse().GetResponseStream())
{
using (MemoryStream memoryStream = new MemoryStream())
{
int count = 0;
do
{
count = remoteStream.Read(buffer, 0, buffer.Length);
memoryStream.Write(buffer, 0, count);
}
while (count != 0);
result = memoryStream.ToArray();
}
}
return result;
}
I getting one image with HTMLAgilityPack and then I want to load it as byte so I could save it in database.
byte[] bIMG = File.ReadAllBytes(doc.DocumentNode.SelectSingleNode("//img[#class='image']").Attributes["src"].Value);
But it says URI formats are not supported. how else I can do that?
EDIT: doc.DocumentNode.SelectSingleNode("//img[#class='image']").Attributes["src"].Value gives a link
The System.IO.File class can't read web URIs - you can use the WebClient for this:
byte[] imageAsByteArray;
using(var webClient = new WebClient())
{
imageAsByteArray = webClient.DownloadData("uri src");
}
i have a C# application where i am using SharpZipLib to deflate a very long string and then send the data over to a PHP Service in a Base64 string of the deflated byte[].
For some reason, when trying to Inflate it on the PHP side, it is returning an error: 'gzinflate: data error'.
How to inflate a gzipped string in PHP?
Here is the C# code:
byte[] sIn = System.Text.UTF8Encoding.UTF8.GetBytes(data);
MemoryStream rawDataStream = new MemoryStream();
GZipOutputStream gzipOut = new GZipOutputStream(rawDataStream);
gzipOut.IsStreamOwner = false;
gzipOut.Write(sIn, 0, sIn.Length);
gzipOut.Close();
byte[] compressed = rawDataStream.ToArray();
// data sent to the php service
string b64 = Convert.ToBase64String(compressed);
PHP code:
$inflated = base64_decode($_POST['data']);
// crash here
$inflated = gzinflate($inflated);
Thanks in advance!
Can't really say why it fails for you with GZipOutStream though I'm guessing it is doing something else then just a pure deflate-compression. I changed your code to use DeflateStream from System.IO.Compression instead and then it worked like a charm.
byte[] sIn = UTF8Encoding.UTF8.GetBytes("testing some shit");
MemoryStream rawDataStream = new MemoryStream();
DeflateStream gzipOut = new DeflateStream(rawDataStream, CompressionMode.Compress);
gzipOut.Write(sIn, 0, sIn.Length);
gzipOut.Close();
byte[] compressed = rawDataStream.ToArray();
// data sent to the php service
string b64 = Convert.ToBase64String(compressed);
Edit
Since the question was about using compression for a Windows Phone project I tried using the DeflateStream from SharpCompress as well and it works just fine, you just have to change which namespace you are using, the classes are the same.
I am trying to upload a base64 encoded string from my mobile phone app (which is written in C#). The string represents an image that needs to be uploaded to my server, which is also written in C#. My client-side code looks like the following:
Client Side Code
----------------
Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters.Add("username", GetUserName());
parameters.Add("imageBytes", Convert.ToBase64String(this.ImageBytes));
string data = string.Empty;
foreach (string key in parameters.Keys)
{
data += key;
data += "=";
data += parameters[key];
data += "&";
}
data = data.Substring(0, data.Length - 1);
uploadWebRequest = (HttpWebRequest)(ar.AsyncState);
using (Stream postStream = uploadWebRequest.EndGetRequestStream(ar))
{
byte[] byteArray = Encoding.UTF8.GetBytes(data); // I believe this has something to do with it. But I believe this is correct. So I think something needs to be done on the server
postStream.Write(byteArray, 0, byteArray.Length);
postStream.Flush();
postStream.Close();
}
uploadWebRequest.BeginGetResponse(new AsyncCallback(Upload_Completed), uploadWebRequest);
when I print out Convert.ToBase64String(this.ImageBytes) in the Watch Window, I receive the following:
Encoded Client String
---------------------
/9j/4AAQSkZJRgABAQEAYABgAAD/4QC4RXhpZgAATU0AKgAAAAgABAESAAMAAAABAAYAAAExAAIAAAAVAAAAPgE7AAIAAAATAAAAVIdpAAQAAAABAAAAaAAAAABXaW5kb3dzIHBob25lIE9TIDcuMAAASGVsbG8gZnJvbSBTZWF0dGxlAAAAApADAAIAAAAUAAAAhpAEAAIAAAAUAAAAmgAAAAAyMDEwOjAxOjAxIDAwOjAwOjAwADIwMTA6MDE6MDEgMDA6MDA6MDAAAAD/4QsnaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLwA8P3hwYWNrZXQgYmVnaW49J++7vycgaWQ9J1c1TTBNcENlaGlIenJlU3pOVGN6a2M5ZCc/Pg0KPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iSW1hZ2U6OkV4aWZUb29sIDguMDMiPg0KCTxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+DQoJCTxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiIHhtbG5zOmV4aWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20vZXhpZi8xLjAvIj4NCgkJCTxleGlmOkRhdGVUaW1lRGlnaXRpemVkPjIwMTAtMDEtMDFUMDA6MDA6MDA8L2V4aWY6RGF0ZVRpbWVEaWdpdGl6ZWQ+DQoJCTwvcmRmOkRlc2NyaXB0aW9uPg0KCTwvcmRmOlJERj4NCjwveDp4bXBtZXRhPg0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA8P3hwYWNrZXQgZW5kPSd3Jz8+/9sAQwACAQECAQECAgICAgICAgMFAwMDAwMGBAQDBQcGBwcHBgcHCAkLCQgICggHBwoNCgoLDAwMDAcJDg8NDA4LDAwM/9sAQwECAgIDAwMGAwMGDAgHCAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwM/8AAEQgJkAzAAwEiAAIRAQMRAf/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/aAAwDAQACEQMRAD8A/fyiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigA
On my server side, I have the following:
Server Side Code
----------------
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult AddPicture(string username, string imageBytes)
{
WriteToTempFileForDebugging(imageBytes);
byte[] tempBytes = Convert.FromBase64String(imageBytes);
using (MemoryStream memoryStream = new MemoryStream(tempBytes))
{
memoryStream.Position = 0;
System.Drawing.Image image = System.Drawing.Image.FromStream(memoryStream);
image.Save("C:\\inetpub\\wwwroot\\MySite\\Pictures\\myImage.png");
}
}
when this code executes, the Image.FromStream(...) line throws an exception. The error says: System.ArgumentException Parameter is not valid. Because of that, I print the 'imageBytes' string to a temporary file. The contents of that temporary file look exactly the same as the encoded string above, with one exception. All of the spaces (" ") in the encoded string have been replaced with plus signs ("+"). I'm guessing this is some encoding issue. However, I'm not sure how to fix it. I don't want to do a find and replace.
How do I resolve this in the proper manner?
Thank you!
You need to call Uri.EscapeDataString before appending each parameter to the POST string.