在通信部分是否有這種配置的開源示例?
https://github.com/blueimp/jQuery-File-Upload
,或者進一步調查jQuery的AJAX調用...
function uploadPicture() {
// blog.w3villa.com/websites/uploading-filesimage-with-ajax-jquery-without-submitting-a-form/
//
var form_data = new FormData(); // Creating object of FormData class
var file_data = photo.src; // Getting the properties of file from file field
// form_data.append("file", file_data); // Appending parameter named file with properties of file_field to form_data
// var blob = new Blob([file_data], {type: 'image/png'});
// form_data.append("file", blob)
var dataURI = photo.src;
alert(dataURI);
form_data.append("file", dataURItoBlob(dataURI));
form_data.append("field1", "stuff1"); // Adding extra parameters to form_data
alert(JSON.stringify(form_data));
$.ajax({
url: serverURL,
dataType: 'json', // the format of the response
cache: false,
contentType: false, // the format of data being sent to the server as part of request
// shazwazza.com/post/Uploading-files-and-JSON-data-in-the-same-request-with-Angular-JS
// setting the Content-type to 'false' will force the request to automatically
// populate the headers properly including the boundary parameter.
// stackoverflow.com/questions/2845459/jquery-how-to-make-post-use-contenttype-application-json
// contentType:"application/json; charset=utf-8",
// contentType:"multipart/form-data; charset=utf-8",
processData: false, // do not convert outgoing data to a string
data: form_data, // Setting the data attribute of ajax with file_data
type: 'post',
success: function(data) {
alert("success! data: " + JSON.stringify(data));
}
});
如果你的手機客戶端是HTML5和JavaScript,它_is_ web應用程序。你認爲在現有的例子中缺乏什麼? – 2012-04-20 05:38:33
示例假定webapp與GAE處於相同的域。對於不是這種情況的移動應用程序。 – 2012-04-20 09:31:06
您可以在應用引擎上設置一個平穩的框架,例如球衣。 – aglassman 2012-04-20 17:00:39