Angular 如何在Ionic中与Cookie一起使用文件传输

Angular 如何在Ionic中与Cookie一起使用文件传输,angular,session,cookies,file-upload,ionic2,Angular,Session,Cookies,File Upload,Ionic2,我试图上传一个图像使用离子本机文件传输,但问题是后端使用会话。如何上传文件并发送cookie,就像我在常规HTTP帖子中所做的那样 我尝试使用标题将withCredentials设置为true,但没有帮助: let options = { quality: 100, saveToPhotoAlbum: false, }; this.camera.getPicture(options).then((imageData) => { const fileTransfer:

我试图上传一个图像使用离子本机文件传输,但问题是后端使用会话。如何上传文件并发送cookie,就像我在常规HTTP帖子中所做的那样

我尝试使用标题将withCredentials设置为true,但没有帮助:

let options = {
    quality: 100,
    saveToPhotoAlbum: false,
};
this.camera.getPicture(options).then((imageData) => {
    const fileTransfer: FileTransferObject = this.transfer.create();
    let options1: FileUploadOptions = {
        fileKey: 'picture',
        fileName: new Date().getTime() + '.jpg',
        httpMethod: 'POST',
        mimeType: "image/jpeg",
        chunkedMode: false,
        headers: {'withCredentials': true},
    }

    fileTransfer.upload(imageData, 'myurl', options1, true)
    .then((data) => {
        alert(JSON.stringify(data));
    }, (err) => {
        alert("error"+JSON.stringify(err));
    });
});
当后端使用会话时,有人知道如何处理吗


提前感谢。

您是否尝试将带有凭据的
直接放在选项中而不是标题中?我解决了删除web视图插件的问题