如何使用extjsrest(AJAX)调用形成上传下载的文件
我需要上传一个使用Extjs Ajax调用下载的文件 下面是我如何努力做到这一点如何使用extjsrest(AJAX)调用形成上传下载的文件,extjs,file-upload,extjs5,Extjs,File Upload,Extjs5,我需要上传一个使用Extjs Ajax调用下载的文件 下面是我如何努力做到这一点 Ext.Ajax.request({ url: '/someRemoteCloudRepository', // url of remote cloud repository from which i download file. method: 'GET', headers: { 'Content-Type': 'application/octet-stream'
Ext.Ajax.request({
url: '/someRemoteCloudRepository', // url of remote cloud repository from which i download file.
method: 'GET',
headers: {
'Content-Type': 'application/octet-stream'
},
success: function(response) { // upon success, i need to upload this file into my server application
var form = Ext.create('Ext.form.Panel', {
items: [{
xtype: 'filefield',
name: 'file_path',
}]
});
form.down('filefield').setValue(response.responseText); // Is this the right way to set the downloaded file content ?
var url = 'uploadFile?id=' + '123';
var params = "size=" + getFileSize(); // how can I get the response data size ?
if (form.isValid()) {
form.submit({
url: url,
params: params,
timeout: 60,
waitMsg: 'Uploading file...',
success: function(formBasic, action) {
Ext.Msg.alert('', 'Upload Failed. Please try again');
},
failure: function(response, opts) {
Ext.Msg.alert('', 'Upload Failed. Please try again');
}
});
}
},
failure: function(response) {
Ext.Msg.alert('Status', 'Failed to download file from remote cloud repo.');
}
});
我可以从远程云服务器下载文件,并在response.responseText
的success:function(response)
中看到数据
然后,我用filefield
创建一个简单表单,并用responseText设置其值,然后执行表单提交。在inspector工具中,我看到正在发送多部分请求,但状态仍处于“挂起”状态或请求超时
从远程源下载后,如何上载文件
我尝试的方法正确吗?如果没有,我怎么做