Skip to Content

ODataModel update call hangs


I have model created ex: var model = new sap.ui.model.odata.v2.ODataModel

when update the model with huge data exl:10kb data browser hangs or no response

ex: model.update(uploadUrl,largebase64Data....

Same works fine for less size content ..

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Dec 05, 2017 at 04:49 AM

    Hi suchin chouta,

    For large files data uploading, it is recommended to use the ajax method for a transaction with the database. Suppose I have an image that I have to upload to OData,

    The view Code :

    <u:FileUploader id="fileUploader" name="myFileUpload"
    						width="400px" tooltip="Upload your file to the local server"
    						uploadOnChange="true" uploadComplete="handleUploadComplete">
    							<u:FileUploaderParameter name="type"
    								value="image/jpeg" />

    In the controller, first get the CSRF token, then update using ajax :

    			 * To upload only the file (using AJAX).
    			 * @public
                                    this._token = this._model.getSecurityToken();
    				var oFileUpload = sap.ui.getCore().byId("fileUploader");
    				var f = evt.oSource.oFileUpload.files[0];
    				var entry = {};
    				entry.Photo = f;
    				var url="proxy/http/XxX.xX.xX.xXx:XXXX/sap/opu/odata/sap/PROJ_SRV/userPhotoSet('"+this._id+"')/$value";
    		        //var oRequest = this.getView().getModel()._createRequest();
    		        var oHeaders = {
    		                  "x-csrf-token": this._token
    		        		//Calling the AJAX function and sending the data, the content type, as well as the CSRF token.
    		                  type: 'PUT',
    		                  headers: oHeaders,
    		                  cache: false,
    		                  contentType: false,
    		                  processData: false,
    		                  data: f,

    Hope this helps,


    Arjun Biswas.

    Add comment
    10|10000 characters needed characters exceeded