【发布时间】:2016-06-08 04:46:00
【问题描述】:
似乎无论我在 iOS 上做什么,我的文件传输都会超时。我目前没有要测试的 android 设备,但它从昨天开始工作。我已经安装了文件传输插件和白名单。
Ionic 框架版本:2.0.0-beta.8, 离子 CLI 版本:2.0.0-beta.30, 离子应用程序库版本:2.0.0-beta.16 Xcode 版本:Xcode 7.3.1
这是我的代码:
upload = (image: string) : void => {
let ft = new Transfer();
let filename = image.substr(image.lastIndexOf('/')+1)+'.jpg';
let options = {
fileKey: 'file',
fileName: filename,
mimeType: 'image/jpeg',
chunkedMode: false,
headers: {
'Content-Type' : undefined
},
params: {
fileName: filename,
apikey: "mykey"
}
};
ft.upload(image, "https://api.ocr.space/parse/image", options, false)
.then((result: any) => {
this.success(result);
}).catch((error: any) => {
this.failed(error);
});
}
每次都会超时并给出这个结果:
[6311:2681244] -[CDVFileTransfer requestForUploadCommand:fileData:]
[Line 224] fileData length: 68706
[6311:2682532] FileTransferError {
body = "";
code = 3;
"http_status" = 0;
source = "file:///var/mobile/Containers/Data/Application/372A03D7-653A-45D8-B59A-EA34252E4AF3/tmp/cdv_photo_006.jpg";
target = "https://api.ocr.space/parse/image";
}
[6311:2682532] File Transfer Error: The request timed out.
【问题讨论】:
-
你能在标题中设置 'Content-Type' : 'image/jpeg' 并尝试一次吗?
标签: ios cordova ionic-framework angular ionic2