IBM / ibm-cos-sdk-js

ibm-cos-sdk-js
Apache License 2.0
38 stars 19 forks source link

Full example #9

Closed smhgit closed 6 years ago

smhgit commented 6 years ago

H

Is there a full example which shows how to upload objects? list the objects? list the buckets?

Can you please also add more details how to set the configuration from the service credentials?

smhgit commented 6 years ago

How to map from here:

{
  "apikey": "xV.......",
  "endpoints": "https://cos-service.bluemix.net/endpoints",
  "iam_apikey_description": "Auto generated apikey ......",
  "iam_apikey_name": "auto-generated-apikey-......",
  "iam_role_crn": "crn:v1:....",
  "iam_serviceid_crn": "crn:v1:bluemix:.....",
  "resource_instance_id": "crn:v1:bluemix:public.......::"
}

To here:

{
  endpoint: '',
  apiKeyId: '',
  ibmAuthEndpoint: '',
  serviceInstanceId: ''
}
nglange commented 6 years ago

The example code in the readme shows the mapping of the values:

    endpoint: '<endpoint>',
    apiKeyId: '<api-key>',
    ibmAuthEndpoint: 'https://iam.ng.bluemix.net/oidc/token',
    serviceInstanceId: '<resource-instance-id>'

For more information on service credentials, check out the docs.

For more information on selecting endpoints, check out the docs.

For more details on how to upload objects using the package, see the API docs.

kyle-apex commented 6 years ago

In addition to the info provided above, here is a full list objects for a bucket example if it helps:

const AWS = require('ibm-cos-sdk');
const s3 = new AWS.S3({
    apiKeyId: "apikey",
    endpoint: "s3-api.us-geo.objectstorage.softlayer.net",
    ibmAuthEndpoint: "https://iam.ng.bluemix.net/oidc/token",
    serviceInstanceId: "resource_instance_id"
});
var params = {
    Bucket : "bucketName",
    MaxKeys: 5000
};

s3.listObjects(params, function(err, data) {
    if (err) {
        console.log('listObjects Error',err, err.stack); // an error occurred
    } else {
        console.log('listObjects Returned',data);        // successful response
    }
});
wbhuberIBM commented 6 years ago

Sufficient information provided in the earlier comments, closing this issue.