0

I have hit a roadblock using the loopback-component-storage with Amazon S3. As a test, I am trying to upload a file to S3 from my browser app, which is calling my loopback API on the backend.

My server config for datasources.json looks like:

  "s3storage": {
    "name": "s3storage",
    "connector": "loopback-component-storage",
    "provider": "amazon",
    "key": “blahblah”,
    "keyId": “blahblah”
  },

My API endpoint is: ‘/api/Storage’

The error response I am getting from the API is as follows:

.   error: {name: "MissingRequiredParameter", status: 500, message: "Missing required key 'Bucket' in params",…}
.   code: "MissingRequiredParameter"
.   message: "Missing required key 'Bucket' in params"
.   name: "MissingRequiredParameter"
.   stack: "MissingRequiredParameter: Missing required key 'Bucket' in params …”
.   status: 500
.   time: "2015-03-18T01:54:48.267Z"

How do i pass the {“params”: {“Bucket”: “bucket-name”}} parameter to my loopback REST API?

Please advice. Thanks much!

  • Bummer. "container" basically translates to "bucket" for S3. I was trying to pass the params object via POST but the devil was in the details i.e. the HTTP POST path for upload was looking for the bucket/container in the path itself. /api/Storage/abc/upload meant 'abc' was the bucket. – Aslam Tajwala Mar 18 '15 at 22:44

2 Answers2

0

AFAIK Buckets are known as Containers in the loopback-component-storage or pkgcloud world.

You can specify a container in your URL params. If your target is /api/Storage then you'll specify your container in that path with something like /api/Storage/container1/upload as the format is PATH/:DATASOURCE/:CONTAINER/:ACTION.

Take a look at the tests here for more examples: https://github.com/strongloop/loopback-component-storage/blob/4e4a8f44be01e4bc1c30019303997e61491141d4/test/upload-download.test.js#L157

Bryan Clark
  • 2,542
  • 1
  • 15
  • 19
  • 1
    This definitely nudged me to think in the right direction. Appreciate the help! I have added a comment to my post above. – Aslam Tajwala Mar 18 '15 at 22:46
0

Bummer. "container" basically translates to "bucket" for S3. I was trying to pass the params object via POST but the devil was in the details i.e. the HTTP POST path for upload was looking for the bucket/container in the path itself. /api/Storage/abc/upload meant 'abc' was the bucket.