Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在使用 Mutagen 将它们保存到磁盘之前验证我的 mp3。但是,使用诱变剂,我只能在磁盘上打开文件。有没有解决的办法?我希望能够做到这一点:
files = request.FILES mp3 = files.get('mp3') mp3_audio = MP3(mp3)
给我错误:
TypeError: invalid file: <TemporaryUploadedFile: test.mp3 (audio/mpeg)>
文件TemporaryUploadedFile对象已经在磁盘上,在为临时文件保留的目录中。要分析它的有效性,请调用一个方法来获取完整路径:
TemporaryUploadedFile
files = request.FILES mp3_temp = files.get('mp3') mp3_audio = MP3(mp3_temp.temporary_file_path())
请参阅TemporaryUploadedFile.temporary_file_path()中的文档