Search code examples
javascriptnode.jsloopback

How can I post a container in Storage api from loopback?


I already have declared my datasource ,my model and the connector between these.

My model

{
  "name": "container",
  "base": "Model",
  "idInjection": true,
  "options": {
    "validateUpsert": true
  },
  "properties": {},
  "validations": [],
  "relations": {},
  "acls": [],
  "methods": {}
}

Datasource

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

My provider

{
  "filesystem": {
    "root": "./server/storage"
  }
}

And the Connector

"container": {
    "dataSource": "storage",
    "public": true
  }

I try posting a object like {"Object":"container1"} into path "./server/storage" but I get the following error from callback.

{
  "error": {
    "statusCode": 500,
    "name": "TypeError",
    "message": "Path must be a string. Received undefined",
    "stack": "TypeError: Path must be a string. Received undefined.."
  }
}

Please who can help me to find my issue? Thanks!


Solution

  • The way to post a container is, without using the loopback api. Create a folder that is gonna be the container into your provider path (being filesystem). As simple as that!