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

下載屬性在保存對話框中不建議文件擴展名

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

問題描述

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

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>

這是服務器響應的樣子:

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 在你的電子主進程中攔截下載.

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

然后你可以調用 downloadItem.setSaveDialogOptions 修改電子將顯示的保存對話框.

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

在保存選項中,您可以指定 FileFilters,它將控制用戶在保存文件時可以選擇哪些擴展名.

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"
  });
});

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

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

相關文檔推薦

How to fix BrowserWindow is not a constructor error when creating child window in Electron renderer process(在 Electron 渲染器進程中創建子窗口時如何修復 BrowserWindow 不是構造函數錯誤) - IT屋-程序員軟件開發技術
mainWindow.loadURL(quot;https://localhost:3000/quot;) show white screen on Electron app(mainWindow.loadURL(https://localhost:3000/) 在 Electron 應用程序上顯示白屏)
Electron webContents executeJavaScript : Cannot execute script on second on loadURL(Electron webContents executeJavaScript:無法在第二個 loadURL 上執行腳本)
how to use electron browser window inside components in angular-cli?(如何在angular-cli的組件內使用電子瀏覽器窗口?)
ElectronJS - sharing redux store between windows?(ElectronJS - 在 Windows 之間共享 redux 存儲?)
How to access camera/webcamera inside electron app?(如何在電子應用程序中訪問相機/網絡攝像頭?)
主站蜘蛛池模板: 欧美一区二区精品 | 日日操av| 日韩成人久久 | 免费在线精品视频 | 日韩在线看片 | 亚洲网站在线观看 | 日韩欧美在线免费观看 | 国产一区欧美 | www.狠狠干| 国产精品国产精品 | 亚洲欧美一区二区三区在线 | 国产xxxx岁13xxxxhd | 久久久国产一区 | 日韩美女爱爱 | 亚洲性人人天天夜夜摸 | 欧美黑人一区二区三区 | 一级在线毛片 | 欧美亚洲国产一区二区三区 | 亚洲综合资源 | 成人精品国产一区二区4080 | 精品久草 | 久久99视频这里只有精品 | 午夜视频免费在线观看 | 九九av| 亚洲一区二区三区视频在线 | 精品一区二区在线观看 | 国产日韩精品久久 | 亚洲在线一区 | 日韩 欧美 二区 | av中文字幕在线播放 | 欧美乱淫视频 | 久久久久久久久91 | 日韩av一区二区在线观看 | 中文字幕在线欧美 | 成人在线播放网址 | 就操在线 | 日韩精品在线看 | av影音资源 | 国产精品不卡 | 伊人色综合久久久天天蜜桃 | 99国产精品视频免费观看一公开 |