2012-12-26 52 views
0

所以我有一個node.js的程序這種反應我使用加入JavaScript字符串變量響應

'Content-Disposition': 'attachment; filename="tts.mp3"' 

相反tts.mp3我有一個名爲textToConvert變量。 我如何添加,並添加.MP3到它的末端有一個爲MP3文件,而不是tts.mp3的名字嗎?

在此先感謝

+0

如...連接具有'+'琴絃? – Ryan

回答

1
'Content-Disposition': 'attachment; filename="' + textToConvert.slice(0, 10) + '.mp3"' 
1
newResponse = response.replace(
    /(filename=")(\w+\.mp3)(")/, '$1' + textToConvert.slice(0, 10) + '.mp3$3');