IBM / ibm-cos-sdk-js

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

Got the error "The specified key does not exist." #18

Closed TopGunBasten closed 6 years ago

TopGunBasten commented 6 years ago

What's wrong with the error? here is the endpoint and ibmAuthEndpoint endpoint: "s3-api.dal-us-geo.objectstorage.softlayer.net", ibmAuthEndpoint: "https://iam.ng.bluemix.net/oidc/token",

widget- commented 6 years ago

The file you were trying to download/modify/access doesn't seem to exist.

It could be that you accidentally entered the wrong name, or that the object you were looking for was never successfully uploaded. Otherwise, it looks like everything is set up properly though.

TopGunBasten commented 6 years ago

I need to upload a file to my bucket, I can use listBuckets to get my bucket data. But once I use putObject method to upload a file under my bucket, I got the message "Unhandled error for request POST /api/object-storage/objects: NoSuchKey: The specified key does not exist". So I need to create a file under my bucket And this is the code I used, I upload the file through api and then pass the buffer of the uploaded to body, any incorrect points?

   cos.putObject({
        Bucket: 's3.gbsqms',
        Key: 'hello',
        Body: req.files[0].buffer,
      },function(err, data) {
        cb(err, data);
      });
widget- commented 6 years ago

I don't see anything that sticks out. I'd maybe double-check that the region you created the bucket in is the same as the region your current config is tied to.

I'm not sure I'll be able to find anything, but would you mind pasting your cos constructor/configuration minus apikey/serviceinstanceid/accesskeys?

TopGunBasten commented 6 years ago

Those are my credentials

  endpoint: "s3-api.dal-us-geo.objectstorage.softlayer.net",
  apiKeyId: "uDA5SQ7SBlZa5fOFACdfJM-mAOS1wd2lHhYYL9jjbEor",
  serviceInstanceId: "crn:v1:bluemix:public:cloud-object-storage:global:a/3496eff1aa4dc5ce59049e0bb8cbf05e:485ac6b3-4a27-43c6-bda2-c2ac2a0bba45::",
TopGunBasten commented 6 years ago

resovle by my self :)

RickyNotaro commented 6 years ago

You can't say

resolved by myself

without posting a potential solution for the futur googlers ! :anger:

thiswallz commented 5 years ago

Just in case you have the same errors, I have solved this passing the stage variable to my lambda.

TopGunBasten commented 5 years ago

please use correct region with the corresponding endpoints

umjohndacosta commented 5 years ago

i found that the endpoints had been changed. from these

auth_endpoint = 'https://iam.bluemix.net/oidc/token'

service_endpoint = 'https://s3-api.us-geo.objectstorage.softlayer.net'

to

auth_endpoint = 'https://iam.bluemix.net/identity/token' service_endpoint = 'https://s3.ap.cloud-object-storage.appdomain.cloud'

how do we contact someone to change / update the course accordingly?

kylanhurt commented 3 years ago

Believe it or not I actually got this error when I incorrectly tried to grab the stream from my LOCAL file, so don't let that fool you.