filepond - filepond 不适用于 safari 中的 video/* 类型
问题描述
我在 react 中使用FilePond 库,它在 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如本票所述
解决方案
浏览器并非都以相同的方式检测文件。根据操作系统,这可能会有所不同。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
推荐阅读
- java - PySpark 错误 - 调用 o33.csv 时出错
- ios - UICollectionView 如何更新单元格?
- count - XQuery 如何使用“where”条件进行计数
- wordpress - 添加标题
- 在第一个之前
- 使用 Wordpress Nav-walker 类的下拉菜单
- python - 如何使用新的 mplfinance 包编辑无花果
- swift - Swift : 使用多个 swift 文件或仅使用一个 viewController?保持清洁
- html - 如何从引导程序修复此导航栏故障。当我按下切换按钮时,它会一直向上滑动
- javascript - Angular 等到订阅完成并为其他函数赋值
- ios - 从 Firebase 中检索没有重复的数据
- java - 点击通知后实现intent方法(NotificationCompat.Builder)