Kevine
Kevine

Reputation: 110

SAPUI5 upload file and use it as model

I would like to upload a xml file from the local workspace and use it as model. I can upload files to the server but i don't know how to retrieve the data from the uploaded object and set or load it to my model

Here is how I m uploading the file.

    jQuery.ajax({
                url: oFileUploader.getUploadUrl(),
                headers: oHeaders,
                type: 'PUT',
                cache: false,
                contentType: false,
                processData: false,
                data: file
            }); 

        }

I could not use the standard oFileUploader.upload() because it uses the http method "POST" and I wanted to do a "PUT"

Thank you

Upvotes: 0

Views: 966

Answers (1)

Serban Petrescu
Serban Petrescu

Reputation: 5206

It is not clear how you get the contents of the file variable that you are passing to the jQuery.ajax call. Depending on this, you have three options hat come to mind:

  1. Directly use the file variable contents in a model.
  2. Use the FileReader API to read the file contents and put them in a model.
  3. Make the back-end service return the XML content of the file as a response to the AJAX call and then store the response in a model.

Upvotes: 1

Related Questions