似乎无论我在iOS上做什么,我的文件传输都会超时。我目前没有安装Android设备,但截至昨天仍在使用。我安装了文件传输插件和白名单。
Ionic Framework版本:2.0.0-beta.8, ionic CLI版本:2.0.0-beta.30, Ionic App Lib版本: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.
答案 0 :(得分:1)
对于iOS 9及更高版本,您需要在发布之前在XCode中添加AppTransportSecurity以允许与HTTP连接。 在XCode中,在info.plist中添加一些键。我遵循的步骤是:
您需要使用自己的文件传输网址更改yourserver.com
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>yourserver.com</key>
<dict>
<!--Include to allow subdomains-->
<key>NSIncludesSubdomains</key>
<true/>
<!--Include to allow HTTP requests-->
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
<!--Include to specify minimum TLS version-->
<key>NSTemporaryExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
</dict>
</dict>
</dict>
答案 1 :(得分:0)
这似乎是端点的一个问题。以下是任何人的上传代码的副本。
//modelBuilder.Entity<IdentityUser>().ToTable("Usuario", "dbo");
var user = modelBuilder.Entity<IdentityUser>()
.ToTable("Usuario", "dbo");
user.HasMany(u => u.Logins).WithRequired().HasForeignKey(ul => ul.UserId);