为什么html5下载不能在我的Meteor项目中运行?

时间:2016-05-04 23:41:48

标签: html5 meteor download iron-router

我只是尝试在链接点击下载文件,如此处http://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_a_download所示或此处显示:

<a href="/images/myw3schoolsimage.jpg" download>
  <img border="0" src="/images/myw3schoolsimage.jpg" alt="W3Schools" width="104" height="142">
</a>

但它不适用于我的Meteor项目。我正在重定向,但没有下载。这有效:

Template.series72.onRendered(function(){
$('.download').attr({target: '_blank', 
                    href  : '../pdfs/sizing-diagram-series-72.pdf'});
});

但我很感兴趣为什么前者不会。谢谢。

1 个答案:

答案 0 :(得分:0)

我个人没有Meteor的经验,所以我可能会遗漏一些东西,但在我看来好像忘记在onRendered函数中添加[HttpPost] [Route("upload")] public async Task<HttpResponseMessage> Upload(uploadFileModel model) { var result = new HttpResponseMessage(HttpStatusCode.OK); if (ModelState.IsValid) { string thumbname = model.VideoThumbName; string tempPath = HttpContext.Current.Server.MapPath("~/video"); string sourceFilePath = Path.Combine(HttpContext.Current.Server.MapPath("~/video"), model.fileName); string pathToThumbs = Path.Combine(HttpContext.Current.Server.MapPath("~/contents/member/" + model.username + "/thumbs"), thumbname + ".jpg"); string finalPath = Path.Combine(HttpContext.Current.Server.MapPath("~/contents/member/" + model.username + "/flv"), model.fileName); string thumbPath = HttpContext.Current.Server.MapPath("~/contents/member/" + model.username + "/thumbs"); string vidDuration = ""; string videoDurationSec = ""; int maxWidth = 380; int maxHeight = 360; try { File.WriteAllBytes(sourceFilePath, model.data); } catch (Exception e) { Console.WriteLine(e.Message); } var ffMpegThumb = new NReco.VideoConverter.FFMpegConverter(); ffMpegThumb.GetVideoThumbnail(sourceFilePath, pathToThumbs); var ffmpegVid = new NReco.VideoConverter.FFMpegConverter(); ffmpegVid.ConvertMedia(sourceFilePath, Format.mp4, finalPath, Format.mp4, new ConvertSettings() { VideoCodec = "h264" }); return result; } else { throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotAcceptable, "This request is not properly formatted")); } } 属性。尝试:

download