0
当我的网站的用户点击链接到.wav文件时,是否可以强制开启Audacity?点击wav链接时打开Audacity
我somethink这样在我的网站:
<a href="link/to/wav/on/server">Click to Listen this awesome track</a>
我使用的前端和作为的NodeJS后端服务器AngularJs。 wav位于NodeJs服务器的子目录中。
当我的网站的用户点击链接到.wav文件时,是否可以强制开启Audacity?点击wav链接时打开Audacity
我somethink这样在我的网站:
<a href="link/to/wav/on/server">Click to Listen this awesome track</a>
我使用的前端和作为的NodeJS后端服务器AngularJs。 wav位于NodeJs服务器的子目录中。
您无法强制计算机本身启动Audacity,这取决于用户的偏好。您可以做的是提示将文件下载到客户端,浏览器可能会建议他通过处理文件扩展名或下载文件的应用程序列表打开它。你可以做到这一点是这样的:
var mime = require('mime'),
fs = require('fs');
app.get('link/to/wav/on/server', function(req, res){
var file = 'filelocationOnTheServer.wav';
res.setHeader('Content-disposition', 'attachment; filename=nameYouWantToGiveit.wav');
res.setHeader('Content-type', 'audio/wav'); // This will make the browser to use the most appropriate app according to it's preference.
// res.setHeader('Content-type', 'application/octet-stream'); // This will never match to anything and will push the browser to ask the user what to do and to download it.
fs.createReadStream(file).pipe(res);
});
如果无畏已经实现了自定义URL方案,例如'大胆将有可能://'(类似于磁铁链接)。 – Midas