Fine uploader, idiomatic way to add download button to each file uploaded

烂漫一生 提交于 2019-12-08 01:26:24

问题


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

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 for the click event on the download button I've added to the markup (e.g. use a fine uploader API method, or my own listener?)
  • How I can associate the necessary information with each button/thumbnail to envoke a file download.

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

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:


  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.

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



来源:https://stackoverflow.com/questions/40377213/fine-uploader-idiomatic-way-to-add-download-button-to-each-file-uploaded

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!