You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2012/06/22 20:42:32 UTC
[18/18] wp7 commit: CB-668 UploadOptions does not serialize Params
CB-668 UploadOptions does not serialize Params
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/commit/f61b3a46
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/tree/f61b3a46
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/diff/f61b3a46
Branch: refs/heads/master
Commit: f61b3a4615fcc35e50b70eb2098da9532a4e68e7
Parents: 9e0b2a9
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Fri Jun 22 10:41:11 2012 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Fri Jun 22 10:41:11 2012 -0700
----------------------------------------------------------------------
framework/Cordova/Commands/FileTransfer.cs | 31 ++++++++++++++---------
1 files changed, 19 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/f61b3a46/framework/Cordova/Commands/FileTransfer.cs
----------------------------------------------------------------------
diff --git a/framework/Cordova/Commands/FileTransfer.cs b/framework/Cordova/Commands/FileTransfer.cs
index eee682a..6c1291c 100644
--- a/framework/Cordova/Commands/FileTransfer.cs
+++ b/framework/Cordova/Commands/FileTransfer.cs
@@ -109,7 +109,7 @@ namespace WP7CordovaClassLib.Cordova.Commands
/// Additional options
/// </summary>
[DataMember(Name="params")]
- public Dictionary<string,object> Params { get; set; }
+ public string Params { get; set; }
/// <summary>
/// Flag to recognize if we should trust every host (only in debug environments)
@@ -244,6 +244,7 @@ namespace WP7CordovaClassLib.Cordova.Commands
/// <param name="options">Upload options</param>
public void upload(string options)
{
+ Debug.WriteLine("options = " + options);
options = options.Replace("{}", "null");
try
@@ -429,11 +430,16 @@ namespace WP7CordovaClassLib.Cordova.Commands
if (uploadOptions.Params != null)
{
- Dictionary<string, object> customParams = uploadOptions.Params;
- foreach (string key in customParams.Keys)
+
+ string[] arrParams = uploadOptions.Params.Split(new []{'&'},StringSplitOptions.RemoveEmptyEntries);
+
+ foreach (string param in arrParams)
{
+ string[] split = param.Split('=');
+ string key = split[0];
+ string val = split[1];
requestStream.Write(boundaryBytes, 0, boundaryBytes.Length);
- string formItem = string.Format(formdataTemplate, key, customParams[key]);
+ string formItem = string.Format(formdataTemplate, key, val);
byte[] formItemBytes = System.Text.Encoding.UTF8.GetBytes(formItem);
requestStream.Write(formItemBytes, 0, formItemBytes.Length);
}
@@ -488,25 +494,26 @@ namespace WP7CordovaClassLib.Cordova.Commands
{
HttpWebRequest webRequest = (HttpWebRequest)asynchronousResult.AsyncState;
using (HttpWebResponse response = (HttpWebResponse)webRequest.EndGetResponse(asynchronousResult))
- {
+ {
using (Stream streamResponse = response.GetResponseStream())
{
using (StreamReader streamReader = new StreamReader(streamResponse))
{
string responseString = streamReader.ReadToEnd();
- Deployment.Current.Dispatcher.BeginInvoke(() =>
- {
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, new FileUploadResult(bytesSent, (long)response.StatusCode, responseString)));
- });
+ Deployment.Current.Dispatcher.BeginInvoke(() =>
+ {
+ DispatchCommandResult(new PluginResult(PluginResult.Status.OK, new FileUploadResult(bytesSent, (long)response.StatusCode, responseString)));
+ });
}
}
}
}
catch (Exception)
{
- Deployment.Current.Dispatcher.BeginInvoke(() =>
- {
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, new FileTransferError(ConnectionError)));
+ Deployment.Current.Dispatcher.BeginInvoke(() =>
+ {
+ FileTransferError transferError = new FileTransferError(ConnectionError, uploadOptions.Server, uploadOptions.FilePath, 403);
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, transferError));
});
}
}