Another way to express this is, is it possible to set the request headers on a form submission? So far I've been unsuccessful. In addition to what I already posted, I also tried this:
Code:
var boundary = '6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm',
parts = new Array();
parts.push('Content-Type: multipart/mixed; boundary=' + boundary);
parts.push('--' + boundary);
parts.push('Content-Disposition: form-data; name="metadata"');
parts.push('Content-Type: application/json;charset=UTF-8');
parts.push('{"version":"2.8.1.RELEASE"}');
parts.push('--' + boundary);
parts.push('Content-Disposition: form-data; name="data"; filename="installation-image.zip"');
parts.push('Content-Type: application/octet-stream');
parts.push('Content-Length: 7340032');
parts.push('--' + boundary);
form.submit({
url: myUrl,
headers: parts, //{'Content-Type':'multipart/mixed; charset=UTF-8'},
/*
params: {
metadata: {'version' : '2.8.1.RELEASE'},
},
*/
waitMsg: 'Uploading your image....',
success: function(form, action) {
me.up('window').destroy();
VFABRIC.util.StatusBarWrapper.setGoodStatus('Successfully uploaded file: ' + action.result.file);
},
failure: function(form, action) {
me.up('window').destroy();
switch (action.failureType) {
case Ext.form.action.Action.CLIENT_INVALID:
VFABRIC.util.StatusBarWrapper.setErrorStatus('Form fields may not be submitted with invalid values');
break;
case Ext.form.action.Action.CONNECT_FAILURE:
VFABRIC.util.StatusBarWrapper.setErrorStatus('Ajax communication failed');
break;
case Ext.form.action.Action.SERVER_INVALID:
VFABRIC.util.StatusBarWrapper.setErrorStatus(VFABRIC.util.AjaxWrapper.getServerErrorMsgs(action.response));
break;
}
},
});
It appears the headers I specify are totally ignored, based on what I see in the Network tab.
If this isn't possible, is there any other way I could do what I need to make the server happy? I'd prefer an Ext solution, but I'll accept a third party way (or rolling my own).