我需要發送一個圖像(JPEG,PNG等)到服務器與參數「access_token」和「照片」(我需要發送的圖像)。發送圖片在WP7
..if (e.TaskResult == TaskResult.OK) {
BitmapImage image = new BitmapImage();
image.SetSource(e.ChosenPhoto);
// foto.Source = image;
Byte[] byteArray;
using (MemoryStream ms = new MemoryStream()) {
WriteableBitmap btmMap = new WriteableBitmap(image);
// write an image into the stream
System.Windows.Media.Imaging.Extensions.SaveJpeg(btmMap, ms, image.PixelWidth, image.PixelHeight, 0, 100);
byteArray = ms.ToArray();
}
((App)Application.Current).get_data(uploadServer + "?photo=" + *HOW I CAN SEND BYTE ARRAY?* + "&access_token=" + ((App)Application.Current).access_token
//
public void get_data(string url,Action<string> qw) {
try {
var request = (HttpWebRequest)WebRequest.Create(
new Uri(url));
request.BeginGetResponse(r => {
var httpRequest = (HttpWebRequest)r.AsyncState;
var httpResponse = (HttpWebResponse)httpRequest.EndGetResponse(r);
HttpStatusCode st = httpResponse.StatusCode;
if (st == HttpStatusCode.NotFound) {
ToastPrompt toast = new ToastPrompt();
toast.TextOrientation = System.Windows.Controls.Orientation.Vertical;
toast.Message = "Ошибка соединения с сервером";
toast.MillisecondsUntilHidden = 2000;
toast.Show();
} else
using (var reader = new StreamReader(httpResponse.GetResponseStream())) {
var response = reader.ReadToEnd();
Deployment.Current.Dispatcher.BeginInvoke(new Action(() => {
qw(response);
}));
}
}, request);
} catch (WebException e) { }
}
UPD:沒有ACCESS_TOKEN需要。 – SevenDays