cancel
Showing results for 
Search instead for 
Did you mean: 

ODataModel update call hangs

0 Kudos

HI

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 ..

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member484715
Contributor
0 Kudos

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:parameters>
							<u:FileUploaderParameter name="type"
								value="image/jpeg" />
						</u:parameters>
					</u:FileUploader>

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



/**
			 * To upload only the file (using AJAX).
			 * @public
			 */			
			handleUploadComplete:function(evt){
                                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.
		        jQuery.ajax({
		                  type: 'PUT',
		                  url:url,
		                  headers: oHeaders,
		                  cache: false,
		                  contentType: false,
		                  processData: false,
		                  data: f,
		                  success:function(){},
		                  error:function(err){console.log(err);}
		        });


			},

Hope this helps,

Regards,

Arjun Biswas.

Thanks for the suggestions

We need to send as batch OData request, as we have multiple calls will be fired.