在哪里将图像和其他组件文件夹放置在环回中? [英] Where to place images and other components folder in loopback?

查看:80
本文介绍了在哪里将图像和其他组件文件夹放置在环回中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想添加博客图像和文档特定的文件夹并获得对项目中文件的访问权,我应该在哪里创建此文件夹,以及如何在前端访问? 我已经测试了公共,服务器和项目根目录上的images文件夹,但无法通过http://localhost:3000/logo.jpghttp://localhost:3000/images/logo.jpg

I want to add blog images and documents specific folder and get access to files in project, where should i make this folders and how can access in front end? I've tested images folder on common, server and project root folder but I couldn't access by something like : http://localhost:3000/logo.jpg or http://localhost:3000/images/logo.jpg

推荐答案

如所述在文档中此处,您应该使用存储组件.您可以定义一个针对本地文件系统的数据源,并应在其中设置要用于提供文件的目录. 文件datasources.json中的数据源配置可能如下所示:

As mentioned here in the docs you should use storage component. you may define a data source targeting your local file system and should set the directory you want to serve the files from in that. Data source configuration in file datasources.json might look like this:

  "files": {
    "name": "files",
    "connector": "loopback-component-storage",
    "provider": "filesystem",
    "root": "./client/storage"
  }

此外,您还需要一个容器模型,其中上面的文件"设置为dataSource. 然后,您可以通过此处

Also you need a container model with above "files" set as dataSource. Then you can access static files through the REST API described here

这篇关于在哪里将图像和其他组件文件夹放置在环回中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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