How to get onUploadProgress in axioms?

I'm a little confused about how to download evt progress with axios.Actually I store huge files with numbers in aws s3. For this, how to get the downloaded progress I need this function onUploadProgress

Currently my mail request is similar to this

export function uploadtoCdnAndSaveToDb(data) {
    return dispatch => {
        dispatch(showUnderLoader(true));
        return axios.post('/posttodb',{data:data},

        ).then((response) => {
            console.log(response.data)
        })
    }
}
+1
source share
2 answers

The Axios repository has a clear example of how to do this: https://github.com/mzabriskie/axios/blob/master/examples/upload/index.html

Excerpt from the Website

When you make a request using axios, you can pass the config request. Part of this config request is a function that should be called at boot.

const config = {
    onUploadProgress: progressEvent => console.log(progressEvent.loaded)
}

axios, .

axios.put('/upload/server', data, config)

, .

, ES6 !

, , , : { data: data }, { data } .

"Fat Arrow Function", , , i.e

(arg) => console.log('hello');

arg => console.log('hello');

, . , . , linter , AirBnB

+9

, , .

"", , onUploadProgress , progressEvent.loaded === progressEvent.total

, , , . , , , development, , , aws s3 bucket

, , , ( )

, ( -) - s3, , , , - .

env, , aws, - ( ec2), s3 0,3 10 ( ), , , → .

. .

, , onUploadProgress , , .

select slow 3g for example to check

+1

All Articles