如何在 SAPUI5 中的 OData 请求正文中传递图像?

How do I pass an Image in the body of a OData Request in SAPUI5?

我需要将 sap.m.Image 文件传递​​给 OData 请求的主体(数据)。下面是代码,我想知道将什么传递给请求的 data 参数,以便我的图像上传到后端。当我传递包含 dataurl 的 ImgValue 时,它给出了一个错误

DOMException: Failed to execute 'createElementNS' on 'Document': The qualified name provided ('d:0') contains the invalid name-start character

OData.request({
    requestUri: "http://ambrifiori.am.brothergroup.net:8081/sap/opu/odata/sap/ZPVSYSTEM_SRV/PromoImagesSet/",
    method: "POST",

    headers: {
        "X-Requested-With": "XMLHttpRequest",
        "Content-Type": "application/atom+xml",
        "DataServiceVersion": "2.0",
        /*"Accept": "application/atom+xml,application/atomsvc+xml,application/xml",  */
        "X-CSRF-Token": header_xcsrf_token,
        "slug": "ajay122",
    },
    data: ImgValue,
});

我无法通过 OData post 图像数据,因此我使用了 ajax... 这就是我所做的。

                OData.request 
            ({  
                requestUri:      "http://AMBRIFIORI.am.brothergroup.net:8081/sap/opu/odata/sap/ZUI5_DAILY_SALES_SRV/DailySalesSet",  
                method: "GET",  
                headers:  
                {       
                    "X-Requested-With": "XMLHttpRequest", 
                    "Content-Type": "application/atom+xml", 
                    "DataServiceVersion": "2.0",          
                    "X-CSRF-Token":"Fetch"                                 }                    
            },  
            function (data, response) 
            { 
                header_xcsrf_token = response.headers['x-csrf-token'];       
                csrftoken = header_xcsrf_token;

                $.ajax({
                      url: 'http://ambrifiori.am.brothergroup.net:8081/sap/opu/odata/sap/ZPVSYSTEM_SRV/PromoImagesSet/',
                      //dataType: 'json',
                      data: imgData,
                      //data: image,
                      type: 'POST',
                        headers: {   "X-Requested-With": "XMLHttpRequest",                        
                            "Content-Type": "image/png", 
                            "DataServiceVersion": "2.0",  
                            /*"Accept": "application/atom+xml,application/atomsvc+xml,application/xml",  */
                            "X-CSRF-Token": csrftoken, 
                            "slug": slug,
                            },                    
                      success: function(data) {
                          debugger;
                        console.log(data);
                        },
                            error: function(data) {
                                debugger;
                                console.log(data);
                            }
                      });                   

我的 ImgData 由数据 URI 格式的 base64 图像组成。我刚刚在我的 Imgvalue 中添加了一条语句,将其转换为 ImgData,即

                var imgData = JSON.stringify(ImgValue);