1. #1
    Sencha User
    Join Date
    Feb 2012
    Posts
    36
    Vote Rating
    2
    mangvlad is on a distinguished road

      0  

    Default Unanswered: File Upload to the server protected with OAuth

    Unanswered: File Upload to the server protected with OAuth


    Trying to upload a file to the server that requires a OAuth token in the header.

    The code is similar to this example: http://dev.sencha.com/deploy/ext-4.0...file-upload.js but it appears that there is no way to add HTTP headers here, since for file upload it always uses HTML form submit and not AJAX, so headers cannot be changed/added...

    Any good work arounds?

    Thanks!

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,582
    Vote Rating
    433
    Answers
    3102
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    Detect file upload and look for the token in form data?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Feb 2012
    Posts
    36
    Vote Rating
    2
    mangvlad is on a distinguished road

      0  

    Default


    From what I understand, current implementation of the form submission will always use HTML instead of Ajax when file upload is needed, so is there a method, event, property that we need to change to switch it to Ajax? If not, is there a way to get file contents and implement submission as a separate "custom" call?

    In other words, here is the code for submit from the sample:


    buttons: [
    { text: 'Save',
    handler: function()
    { var form = this.up('form').getForm();
    if(form.isValid())
    { form.submit(
    { url: 'file-upload.php',
    waitMsg: 'Uploading your photo...',
    success: function(fp, o)
    { msg('Success', 'Processed file "' + o.result.file + '" on the server');
    } }); } } }


    Adding "headers": "Test:test" will not work here once form has a field of the type file...

    (Not sure I am very clear here about the problem...)