To send custom headers with file upload to pass authorization we have to set xhr2: true in submit options. But in this case file itself is not sent, if not use xhr2, then you can't send authorization headers, so can't upload file with Ext (have to manually use FormData or other ways).
But I want it to work with Ext!
It appeared, that Ext.dataConnsection.setOptions has such line:
Code:
data = options.rawData || options.binaryData || options.xmlData || jsonData || null;
but previously options already has "data" set in Ext.form.Panel.beforeAjaxSubmit:
Code:
    if (Ext.feature.has.XHR2 && request.xhr2) {        delete request.form;


        formData = request.data = new FormData(form);


        if (request.params) {
            Ext.iterate(request.params, function(name, value) {
                if (Ext.isArray(value)) {
                    Ext.each(value, function(v) {
                        formData.append(name, v);
                    });
                }
                else {
                    formData.append(name, value);
                }
            });


            delete request.params;
        }
    }
request object then send as options in setOptions.
The problem is that in the request call is sent result of setOptions, which ignores options.data, so file is not sent.
So options.data should be added here:
Code:
data = options.rawData || options.binaryData || options.xmlData || jsonData || options.data || null;
But setOptions is quite complex, so to fix it I've overrided it in such way:
Code:
Ext.define('App.overrides.data.Connection', {
    override: 'Ext.data.Connection',


    setOptions: function(options, scope) {
        let params = this.callParent(arguments);


        if (!params.data && options && options.data) {
            params.data = options.data;
        }


        return params;
    }
});
It almost solved the issue for me, but in Ext.data.request.Ajax.setupHeaders there is check, if data is set, but options.headers has no Content Type set, then content type is set by data, that breaks Content Type for multipart/form...
To avoid this, just set in submit options headers: { 'Content-Type': null }
It could be seen in the fiddle https://fiddle.sencha.com/#view/editor&fiddle/344g

Hope this will help someone, as the ability to upload files with needed headers by standard Ext calls should work out of the box.
And maybe someone will fix this in next releases