精细上传,惯用的方式为每个上传的文件添加下载按钮 [英] Fine uploader, idiomatic way to add download button to each file uploaded

查看:120
本文介绍了精细上传,惯用的方式为每个上传的文件添加下载按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已成功将罚款上传器应用到我的项目中。我正在使用 addInitialFiles 方法用以前的方法填充它上传文件。

I've successfully implemented fine uploader into my project. I'm using the addInitialFiles method to populate it with previously uploaded files.

我想做的是为每个呈现的文件预览添加一个下载按钮,用户添加文件和使用addInitialFiles预填充时加载 。将按钮添加到标记模板非常简单,但我仍然坚持最惯用的方式:

What I would like to do is add a download button to each file preview rendered, both as a user add's files and 'on load' when prepopulated using addInitialFiles. Adding the button to the mark up template is pretty trival, but I'm stuck on what the most idiomatic way would be to:


  • Listen对于我已添加到标记的下载按钮上的click事件(例如,使用一个精细的上传器API方法,或我自己的监听器?)

  • 如何将必要的信息与每个按钮/缩略图以调用文件下载。

我将文件下载URL存储在mongo集合中,即我返回并填充使用的addInitial文件方法。

I'm storing the files download url in a mongo collection that that im returning and populating the addInitial files method with.

如果出现这种情况:我不打算让下载器处理好上传,我只是想编织将功能下载到它的UI中:)

In case it comes up: I'm not looking to have fine uploader 'handle' the download, I'm simply trying to weave the download functionality into it's UI :)

欣赏任何/所有建议/指针!

Appreciate any/all advice/pointers!

推荐答案


  1. < li> 内的某处添加一个锚链接到你的模板。

  2. 听取 qq.status.UPLOAD_SUCCESS 状态更改。

  3. 成功时,更新锚链接以指向相应的下载端点。您可以使用 getItemByFileId

  1. Add an anchor link to your template somewhere inside the <li>.
  2. Listen for qq.status.UPLOAD_SUCCESS status changes.
  3. On success, update the anchor link to point to the appropriate download endpoint. You can find the anchor link for a specific file using getItemByFileId.

您需要确保服务器返回正确的<响应下载GET请求时,code> Content-Disposition 标题。

You'll need to be sure your server returns the proper Content-Disposition header when responding to a download GET request.

这篇关于精细上传,惯用的方式为每个上传的文件添加下载按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆