su27 / qcloud_cos_py3

A 3rd-parth SDK for Qcloud COS and Python 3
MIT License
8 stars 0 forks source link

Get code -48, message ERROR_UNKNOWN when upload file. #1

Closed kirbylynx closed 6 years ago

kirbylynx commented 6 years ago

Get response {'code': -48, 'message': 'ERROR_UNKOWN', 'request_id': '*****'} when using upload_file. Any idea?

su27 commented 6 years ago

The message is too brief, I can't idenfity where the problem is. Maybe you can check if everything(environment, apikey/secret, path, local file) is ok and give more tries.

kirbylynx commented 6 years ago

You are sure this SDK currently works fine, right? Maybe it's my local problem.

su27 commented 6 years ago

Yes, you can run the testcases (I just checked), which have covered all the functions in the SDK and have made sure they work fine.

https://cloud.tencent.com/document/product/436/8432 Here's the error code table, but -48 is undocumented, unfortunately.

kirbylynx commented 6 years ago

OK, thanks.

kirbylynx commented 6 years ago

Is this right?

with open(local_file_name, "rb") as f:
    file_object = f.read()
    r = bucket.upload_file(file_object, "test.jpg",
                           "testdir", mime='image/jpeg')
    f.close()
kirbylynx commented 6 years ago

I'm pretty sure there is something wrong with upload_file. the parameter of "cos_path" in function of "sign_more" is empty. This may be the cause of my problem.

su27 commented 6 years ago

Are you sure you're using my latest code? Because if you do this:

r = bucket.upload_file(file_object, "test.jpg", "testdir", mime='image/jpeg')

You will get a fatal error because only 2 positional arguments are allowed: https://github.com/su27/qcloud_cos_py3/blob/master/qcloud_cos_py3/cos.py#L167

And the cos_path must be empty.