We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I am trying to get the file type from request data and save it, but the saved file can't use if I call filetype.guess( audio_file ).
filetype.guess( audio_file )
I also try to save the data first, read the saved file and save again after i checked the file type, the saved file can't use too.
how to I solved this problem?
audio_file = request.files['data'] kind = filetype.guess( audio_file ) if kind is not None : file_type = kind.extension wav_path = os.path.join( current_app.config['UPLOAD_FOLDER'], 'audio.'+file_type )
audio_file = request.files['data'] tmp_path = os.path.join( current_app.config['UPLOAD_FOLDER'], "upload_audio.tmp" ) audio_file.save( tmp_path ) tmp_file = open( tmp_path , 'rb' ) tmp_data = tmp_file.read() kind = filetype.guess( tmp_data ) tmp_file.close() if kind is not None : file_type = kind.extension wav_path = os.path.join( current_app.config['UPLOAD_FOLDER'], wav_id+'.'+file_type ) wav_file = open( wav_path , 'wb' ) wav_file.write( tmp_data ) wav_file.close()
The text was updated successfully, but these errors were encountered:
@Winedays Do you have an example url? I did not get your problem. Are you unable to check the file type or unable to play the audio file?
Have you had a look here? #62 (comment)
Sorry, something went wrong.
No branches or pull requests
I am trying to get the file type from request data and save it, but the saved file can't use if I call
filetype.guess( audio_file )
.I also try to save the data first, read the saved file and save again after i checked the file type, the saved file can't use too.
how to I solved this problem?
The text was updated successfully, but these errors were encountered: