【发布时间】:2015-11-12 16:58:40
【问题描述】:
我的图片上传无法在 iOS 上运行。它在 Android 上运行良好,但 iOS 导致问题。 这是我的代码:
var server = URLS.INDEX + 'items';
var options = {
fileKey: 'itemPic',
params: newItemData,
chunkedMode : false,
headers: {
'x-access-token': authService.getApiToken(),
Connection: "close"
}
};
$cordovaFileTransfer.upload(server, filePath, options)
.then(function (result) {
postNewItemPromise.resolve();
$state.go('slider.me', {}, {
reload: true
}).then(function () {
$rootScope.$broadcast('newItemAdded');
});
}, function (err) {
postNewItemPromise.reject();
if (err.status === 401) {
authService.reAuth();
}
}, function (progress) {
});
我收到以下错误:
body: "{\"message\":\"Unexpected token u\",\"error\":{}}"
code: 3
exception: null
http_status: 400
source: "file:///var/mobile/Containers/Data/Application/7B768C78-48F1-4A8B-BDC8-35F1C93AEC76/tmp/cdv_photo_007.jpg"
target: "xxxx"
我发现了很多关于类似问题的帖子,但他们都用 Connection : "close" 和 chunkedMode : false 解决了这个问题。不过这对我不起作用。
我认为问题在于文件传输插件无法正确解析我的 newItemData 对象中的数组和对象。我不知道如何解决这个问题。
【问题讨论】:
标签: ios cordova ionic cordova-plugins ngcordova