久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

下載屬性在保存對(duì)話框中不建議文件擴(kuò)展名

download attribute not suggesting file extension in save dialog(下載屬性在保存對(duì)話框中不建議文件擴(kuò)展名)
本文介紹了下載屬性在保存對(duì)話框中不建議文件擴(kuò)展名的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

我正在使用下載鏈接,在電子中,鏈接打開(kāi),但 Save as type 只顯示 All Files (*.*) 有沒(méi)有辦法使用電子僅使用 <a> 標(biāo)記在該字段中強(qiáng)制文件擴(kuò)展名?這在顯示 MY_EXTENSION (*.my_extension) 的 chrome 中有效,但在電子中卻沒(méi)有.如果您在新名稱中重命名沒(méi)有擴(kuò)展名的文件,這很有用,下載時(shí)會(huì)自動(dòng)添加它.

I am using a download link and in electron, the link opens but the Save as type only shows All Files (*.*) Is there a way for electron to force a file extension in that field using just an <a> tag? This works in chrome where it shows MY_EXTENSION (*.my_extension), but in electron it does not. This is useful for if you rename the file without the extension in the new name, it will automatically add it when downloaded.

鏈接如下:

<a href="/path/to/file.my_extension" download>Download File</a>

這是服務(wù)器響應(yīng)的樣子:

Here is what the server response looks like:

res.set('Content-disposition', 'attachment; filename=' + req.params.name + '.my_extension');
res.set('Content-Type', 'application/zip');

推薦答案

你可以使用 DownloadItem 在你的電子主進(jìn)程中攔截下載.

You can use DownloadItem in your main process in electron to intercept the download.

然后你可以調(diào)用 downloadItem.setSaveDialogOptions 修改電子將顯示的保存對(duì)話框.

Then you can call downloadItem.setSaveDialogOptions to modify the save dialog that will be displayed by electron.

在保存選項(xiàng)中,您可以指定 FileFilters,它將控制用戶在保存文件時(shí)可以選擇哪些擴(kuò)展名.

In the save options you can specify the FileFilters which will control from which extensions the user can choose when saving the file.

例子:

// in your main process:
const { BrowserWindow } = require('electron');

// create the default window
let win = new BrowserWindow();

// handle download event
win.webContents.session.on('will-download', (event, item, webContents) => {
  // TODO: find out what the user is downloading and set options accordingly
  item.setSaveDialogOptions({
    filters: [
      // Set your allowed file extensions here
      {name: "My Special Filter", extensions: ["special"]},
      {name: "Images", extensions: ["jpg", "png"]
    ],
    message: "Please pick your poison"
  });
});

這篇關(guān)于下載屬性在保存對(duì)話框中不建議文件擴(kuò)展名的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

How to fix BrowserWindow is not a constructor error when creating child window in Electron renderer process(在 Electron 渲染器進(jìn)程中創(chuàng)建子窗口時(shí)如何修復(fù) BrowserWindow 不是構(gòu)造函數(shù)錯(cuò)誤) - IT屋-程序員軟件開(kāi)發(fā)技術(shù)
mainWindow.loadURL(quot;https://localhost:3000/quot;) show white screen on Electron app(mainWindow.loadURL(https://localhost:3000/) 在 Electron 應(yīng)用程序上顯示白屏)
Electron webContents executeJavaScript : Cannot execute script on second on loadURL(Electron webContents executeJavaScript:無(wú)法在第二個(gè) loadURL 上執(zhí)行腳本)
how to use electron browser window inside components in angular-cli?(如何在angular-cli的組件內(nèi)使用電子瀏覽器窗口?)
ElectronJS - sharing redux store between windows?(ElectronJS - 在 Windows 之間共享 redux 存儲(chǔ)?)
How to access camera/webcamera inside electron app?(如何在電子應(yīng)用程序中訪問(wèn)相機(jī)/網(wǎng)絡(luò)攝像頭?)
主站蜘蛛池模板: 99精品视频在线观看 | 99re视频在线 | 国产一区二区三区四区在线观看 | 国产高清精品一区二区三区 | 日日摸夜夜添夜夜添特色大片 | 日韩色图在线观看 | 黄 色 毛片免费 | 久久精品国产一区二区电影 | 久综合| 成人精品一区 | 黄色香蕉视频在线观看 | 日本一区二区三区免费观看 | 日韩欧美理论片 | 久久久国| 91亚洲精品国偷拍自产在线观看 | 91性高湖久久久久久久久_久久99 | 中文字幕日韩一区 | 欧美一级大片免费看 | 日日拍夜夜 | 免费能直接在线观看黄的视频 | 欧美精品一区二区三区在线 | 日韩欧美三区 | 婷婷丁香在线视频 | a视频在线观看 | 免费av播放| 无码一区二区三区视频 | 欧美一区视频 | 久久这里有精品 | 国产91丝袜在线熟 | 欧美videosex性极品hd | 精品欧美一区二区三区久久久 | 久久成人免费视频 | 亚洲精品二区 | 成人二区 | 日韩一区二区免费视频 | 久久精品免费 | 国产福利在线免费观看 | 久久久不卡网国产精品一区 | 毛片免费视频 | 亚洲精品综合 | 国产精品入口 |