Search code examples
javascriptangularjsflow-js

flowjs upload method is undefined


I'm new with flow.js, and i'm using the ng-flow implementation. I want to do something but i don't know if it is possible or not, and if it is so, how to do this. I have write a factory that catch all the events, and i need that when it catch the FilesSubmitted event, this factory have to upload automatically the file. Following the flowJs documentation here i have found some methods and attributes for the 'file' element, but when i look in the console.log(file) for the upload() method, i didn't find it, like it doesn't exist. I supposed that maybe the resume() function call the method inside itself, but neither that thing works.


Solution

  • Based on the official documentation:

    <div flow-init="{target: '/upload'}" flow-files-submitted="$flow.upload()"></div>
    

    As long as flow-files-submitted="$flow.upload()" is set with flow-init, the file will auto-upload once it is selected from the picker. If you remove this, you will have to create another button (similar to Pause/Resume/Cancel) and assign it to upload() to initiate the upload manually.

    Something like this:

    <button ng-click="$flow.upload()">Upload</button>
    <button ng-click="$flow.pause()">Pause</button>
    <button ng-click="$flow.resume()">Resume</button>
    <button ng-click="$flow.cancel()">Cancel</button>