IBM / ibm-cos-sdk-js

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

NoSuchKey error while uploading file to COS bucket. #65

Closed engineerpassion closed 4 years ago

engineerpassion commented 4 years ago

I'm using the URL of the location where the bucket resides, but I'm still seeing the issue.

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/ibm_botocore/client.py in _make_api_call(self, operation_name, api_params)
    659             error_code = parsed_response.get("Error", {}).get("Code")
    660             error_class = self.exceptions.from_code(error_code)
--> 661             raise error_class(parsed_response, operation_name)
    662         else:
    663             return parsed_response

NoSuchKey: An error occurred (NoSuchKey) when calling the PutObject operation: The specified key does not exist.

Here is my code:

import ibm_boto3
from ibm_botocore.client import Config, ClientError

cos_client = ibm_boto3.resource("s3",
    ibm_api_key_id=COS_API_KEY_ID,
    ibm_service_instance_id=COS_RESOURCE_CRN,
    ibm_auth_endpoint="https://iam.bluemix.net/oidc/token",
    config=Config(signature_version="oauth"),
    endpoint_url=COS_ENDPOINT
)
with open(training_data_file_name, "rb") as file_data:
    cos_client.Object('credit-risk-training-data', training_data_file_name).upload_fileobj(
        Fileobj=file_data
    )

By bucket resides in us-geo and I'm using https://s3.us.cloud-object-storage.appdomain.cloud as the COS_ENDPOINT.

sandersrIBM commented 4 years ago

Hi @engineerpassion - Can you please provide more of your code? From the looks of it, it seems as though a bucket is not being provided.

engineerpassion commented 4 years ago

@sandersrIBM The issue is resolved, I raised the same in a different tracker. Closing this. Thanks.