используя оболочку мы можем открыть файл с помощью приложения по умолчанию.Но возможно ли blob
что преобразовать в файл?
var fileurl = ''; //url of a file, example is docx file.
var filename = $(this).text().replace(/^\s+/g, '');
$.ajax({
url: fileurl,
method: 'GET',
xhrFields: {
responseType: 'blob'
},
success: function (data) {
//convert the blob into file
var file = new File([data], filename, {type: data.type, lastModified: Date.now()});
const {shell} = require('electron');
shell.openItem(file); //open the converted file with it's default application
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
Я пытался преобразовать BLOB-объект в файл, думая, что, возможно, он будет работать, но не получится, и ошибка говорит Error processing argument at index 0, conversion failure from #<File>
.