如何从本地文件路径创建文件对象 [JavaScript]
How to create file object from local file path [JavaScript]
我正在用 meteor 制作 cordova ios 应用程序。我正在使用一个定制的相机插件。录制视频后,我只得到该视频的本地路径。我必须使用该路径创建 File 对象。我尝试了 new File('etc/path')
但它不起作用。
编辑:
我尝试制作 blob 和制作 New File([blob], 'name)
,但这也不起作用。
谢谢,
伊戈尔
谢谢@Bertrand,你给了我解决问题的方法。我写了这个:
window.requestFileSystem(window.TEMPORARY, 5 * 1024 * 1024, function (fs){
fs.root.getFile('output.mov', { create: true, exclusive: false }, function (fileEntry) {
fileEntry.file(function (file){
console.log(file)
});
}, (err) => {
console.log(err)
});
}, (err) => {
console.log(err)
});
我正在用 meteor 制作 cordova ios 应用程序。我正在使用一个定制的相机插件。录制视频后,我只得到该视频的本地路径。我必须使用该路径创建 File 对象。我尝试了 new File('etc/path')
但它不起作用。
编辑:
我尝试制作 blob 和制作 New File([blob], 'name)
,但这也不起作用。
谢谢,
伊戈尔
谢谢@Bertrand,你给了我解决问题的方法。我写了这个:
window.requestFileSystem(window.TEMPORARY, 5 * 1024 * 1024, function (fs){
fs.root.getFile('output.mov', { create: true, exclusive: false }, function (fileEntry) {
fileEntry.file(function (file){
console.log(file)
});
}, (err) => {
console.log(err)
});
}, (err) => {
console.log(err)
});