Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

transformResponse() not being called with POST operation of a RestDataSource

$
0
0
SmartClient Version: v9.1p_2015-03-26/Pro Developmentv

I am trying to upload a file to a REST API and have a callback execute when the file has been uploaded. Below are the relevant portions of my SmartClient code.

Code:

uploadFile: function () {

    var fileUploadDS, fileUploadForm;

    fileUploadDS = isc.RestDataSource.create({
        dataFormat: "json",
        dataURL: isc.Page.getAppDir() + "rest/uploadFile",
        fields: [
            {name: "file", type: "FileItem"}
        ],

        transformResponse: function(dsResponse, dsRequest, data) {
(1)        var dsResponse_o = this.Super("transformResponse", arguments);
            return dsResponse_o;
        }
    });

    fileUploadForm = isc.DynamicForm.create({
        dataSource: fileUploadDS,
        width: 300,

        fields: [{
            name: "file",
            type: "FileItem",
            title: "Upload file",
            width: 400,
            canEdit: true,
            required: true,
            multiple: false
        }, {
            title: "Upload",
            type: "button",
            click: function () {
(2)            this.form.saveData();
            }
        }
        ]
    });

    ....
}

When I click the Upload button (2), I see my POST being executed and I get a 200 response from the server the response data in the SmartClient format:
Code:

  {"response":{"data":"Ok","invalidateCache":false,"isDSResponse":true,"affectedRows":0,"status":0}}
and the file was successfully uploaded to the server. However, my breakpoint at (1) does NOT get triggered.

What does occur is after a few minutes, my breakpoint at (1) is triggered, but the dsResponse has a status of -100 and the data is "Operation timed out".

I have used the RestDataSource successfully for GET and DELETE and the callback is always executed at the correct time i.e. when the client receives the response from the server.

What am I doing wrong?

Viewing all articles
Browse latest Browse all 4756

Trending Articles