I have a problems saving video files on server using flask. Here is my client code( I am using react and super agent):
onDrop(files){
var req = request.post('/upload');
files.forEach((file)=> {
req.attach('videoFile', file);
});
req.end(() => this.fileUploaded(files[0].name));
}
And server method
@app.route('/upload', methods=["POST"])
def upload():
try:
fileName = '{0}{1}{2}'.format('zz', ''.join(random.sample(char_set, 8)), '.mp4')
path = os.path.join('web', app.config['UPLOAD_FOLDER'], fileName)
url = '/video/{0}'.format(fileName)
file = request.files['videoFile']
if file:
file.save(path)
return flask.jsonify({'success': True , 'fileName': url})
except Exception as ex:
return flask.jsonify({'success': False, 'message': ex})
This code uploads and saves file on server, but after uploading this file become corrupted, and i can't play it this any video player.
I will be grateful for any help or advice