Error when uploading file (cordova-plugin-file-transfer)

I’m using cordova-plugin-file-transfer to change user’s profile photo on my app.

It works without any error once and then, on the next try, it gives error. It is happening over and over again, success, error, success, error.

Do you have any idea why this is happening?

Thanks in advance

FileTransferError with code 1 and http_status 501