2016-06-08 5 views
0

내 웹 사용자가 .wav 파일에 대한 링크를 클릭하면 Audacity를 강제로 열 수 있습니까? wav 링크를 클릭하면 Audacity가 열림

나는 내 웹 사이트에이 같은 somethink 가지고 :

<a href="link/to/wav/on/server">Click to Listen this awesome track</a> 

내가 백엔드 서버와 프런트 엔드 NodeJs에 대한 AngularJS와를 사용합니다. wav는 NodeJs 서버의 하위 디렉토리에 있습니다.

+0

Audacity에서 'audacity : //'(자석 링크와 유사)와 같은 맞춤 URL 스키마를 구현 한 경우 가능합니다. – Midas

답변

0

컴퓨터에서 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); 
}); 
관련 문제