使用 Angular 从目录提供下载服务

Serve Downloads from Directory using Angular

我在提供 Angular 应用程序的同一个文件夹中有一个文档列表。我想制作一个显示文档列表的网页,以及下载单个文档的链接。

我该如何完成?

虽然通常建议通过您自己的后端提供文档,但您可以通过使用一些标准 angular 包来简化这项工作。以下是一些选项:

  1. ngx-doc-viewer - Probably the best library and support a lot of file types. This demo可以帮助您更好地了解它。
  2. ng2-pdf-viewer - When your concerns are limited to pdf, this is a much simpler package to use, but do not have a wide range of customizations.Stackblitz demo
  3. ngx-extended-pdf-viewer - This has a wide range of customizations and can be really cool if your concerns are regarding doc display with a toolbar.Demo
  4. NodeJs + DB - 最后但并非最不重要的一点是,复杂应用程序最可定制和标准的方法是构建您自己的后端。后台服务器其实可以给docs分配一个文件夹,文档可以uploaded/saved到users/admin在那个特定的文件夹里。