有没有办法可以强制从 Amazon S3 下载 MP3 文件。我的 Razor 中有一个下载按钮: <td> <a href="@t.S3PreSignedUrl" class="js_recordingDownloadButton document-link btn btn-info btn-block br2 btn-xs fs12 @Html.Raw(t.S3PreSignedUrl.IsNullOrWhiteSpace() ? "disabled" : "")" target="_blank" data-container="body" data-toggle="tooltip" title="@t.OriginalFilename" type="@t.MimeType" download> <span class="fa fa-cloud-download fs12"></span> </a> </td>当前,当您单击它时,会打开另一个浏览器窗口并开始使用 Modal 自动播放:<div id="js_PlayRecordingPopup" class="popup-basic mfp-with-anim modalPopup"> <div class="panel"> <div class="admin-form"> <div class="panel-heading"> <span class="panel-title"> <i class="fa fa-play"></i> Play Recording </span> </div> </div> <div class="panel-body bt0 text-center p25"> <p class="popupInfo fs12 mb5">Playing: <b class="text-info js_playingTitle"></b></p> <p class="popupInfo fs12">Filename: <b class="text-info js_playingFileName"></b></p> <div class="summaryBox popupSummary text-center audioContainerBox"> <audio controls controlsList="nodownload" id="audRecording"> Your browser does not support the audio element. </audio> </div> </div> <div class="panel-footer"> <div class="text-center"> <input type="button" class="btn btn-primary" value="Done" data-bind="click: function(){ var sound = document.getElementById('audRecording'); if(sound != undefined) { sound.pause(); sound.currentTime = 0; } $.magnificPopup.close(); }"> </div> </div> </div> <button title="Close (Esc)" type="button" class="mfp-close" data-bind="click: function(){ var sound = document.getElementById('audRecording'); if(sound != undefined) { sound.pause(); sound.currentTime = 0; }}">×</button></div>有没有办法设置它,以便如果我单击“下载”它会立即下载文件?
1 回答
动漫人物
TA贡献1815条经验 获得超10个赞
您可以更改
Content-Type
对 的响应Content-Type: application/octet-stream
。同时也设置Content-Disposition: attachment; filename="filename.mp3"
。确保文件名使用RFC 5987 中定义的编码我看到您已经
download
在 HTML5 上找到了该属性,但您没有提供文件名。它应该像这样使用:
<a href="pathtofile.mp3" download="filename">
你总是可以测试这个download.js通过dandavis写的。如果可行,您可以反转他的代码。
- 1 回答
- 0 关注
- 200 浏览
添加回答
举报
0/150
提交
取消