Skip to Content
0
Dec 13, 2015 at 02:30 PM

FileUploader - 405 Method Not Allowed

2110 Views

Hello Experts,

I've followed the excellent set of blogs by Peter Marcely regarding SAPUI5 & Gateway attachments.

I would like to implement file uploading without entities associations.

The code is from this blog:

http://scn.sap.com/community/developer-center/front-end/blog/2014/07/28/upload-image-to-sap-gateway-and-display-image-in-ui5--using-new-fileuploader-with-sap-gateway

var oFileUploader = new sap.ui.unified.FileUploader({  
    uploadUrl : "/sap/opu/odata/sap/<service>/AttachmentCollection('1')/$value",  
        name: "simpleUploader",   
        uploadOnChange: false,  
        sendXHR: true,  
        useMultipart: false,  
        headerParameters: [  
            new sap.ui.unified.FileUploaderParameter({name: "x-csrf-token", value: sCSRF })
        ],  
        uploadComplete: function (oEvent) {  
            var sResponse = oEvent.getParameter("response");  
                if (sResponse) {  
                    sap.ui.commons.MessageBox.show("Return Code: " + sResponse, "Response", "Response");  
        }  
        }                      
});  

// create a button to trigger the upload  
var oTriggerButton = new sap.ui.commons.Button({  
    text:'Upload',  
        press:function() {  
        // call the upload method  
        oFileUploader.insertHeaderParameter(new sap.ui.unified.FileUploaderParameter({name: "slug", value: oFileUploader.getValue() }));
                oFileUploader.upload();  
        }  
});  


The problem is that I'm getting '405 Method Not Allowed' when running from SAPUI5 (the method is automatically set to POST).

If I run this from gateway client and add a file, the method changes to PUT and it works.

Both create_stream and update_stream methods are implemented.

How can I solve this issue?

Regards,

Omri