0
我无法让我的图像上传在iOS上运行。它在Android上正常工作,但iOS导致问题。 这里是我的代码:IOS上的Cordova文件上传错误
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"
我发现有关类似问题很多帖子,但他们都解决了这个与连接:“关闭”和chunkedMode:假。虽然这不适合我。
我认为问题在于文件传输插件无法正确解析我的newItemData对象中的数组和对象。我不知道如何解决这个问题。