问题
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
回答1:
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"
}
Also you need a container model with above "files" set as dataSource. Then you can access static files through the REST API described here
来源:https://stackoverflow.com/questions/47732182/where-to-place-images-and-other-components-folder-in-loopback