如何解决filepond不适用于Safari中的视频/ *类型
我在反应中使用FilePond library,在chrome中有效,但在safari中则不能。 我的问题是:
当我设置acceptedFileTypes={['video/*']}
- Chrome浏览器-接受所有视频类型。
- 在safari中-仅接受
mov
个文件,而不是所有视频类型的文件。
当我设置acceptedFileTypes={['video/mp4']}
时:两者都符合预期的行为,并且仅接受mp4文件。
我不想设置所有可能的视频类型,而是希望使用video/*
过滤器。
Safari版本:13.1.1
<FilePond
ref={fileRef}
files={files}
allowMultiple={false}
labelIdle={labelIdle}
className="video"
instantUpload={false}
onupdatefiles={(items) => {
setFiles(items)
}}
onremovefile={() => toggleDisplayProgress(false)}
acceptedFileTypes={['video/*']}
required
/>
我可以在此处专门设置视频类型-如https://trac.webkit.org/browser/trunk/Source/WebCore/platform/MIMETypeRegistry.cpp
所述in this ticket解决方法
浏览器并非都以相同的方式检测文件。根据操作系统的不同,可能会有所不同。 fileValidateTypeDetectType
挂钩有助于检测正确的类型。您可以使用它来基于文件扩展名手动设置正确的类型。
FilePond.create(document.querySelector('input'),{
acceptedFileTypes: ['image/png'],fileValidateTypeDetectType: (source,type) => new Promise((resolve,reject) => {
// Do custom type detection here and resolve promise
resolve(type);
})
});
请参阅:https://pqina.nl/filepond/docs/patterns/plugins/file-validate-type/#custom-type-detection
,我最终使用了quicktime
和mp4
,它们起作用了:
acceptedFileTypes={['video/quicktime','video/mp4']}
。
无法在野生动物园中使用video/*
。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。