在 IDLE 中运行代码时,它什么也不显示。
从 ibm_botocore.client 导入配置
导入 ibm_boto3
def upload_file(凭证,local_file_name,key):
cos = ibm_boto3.client(service_name='s3', ibm_api_key_id=credentials['从服务凭证描述中得到'],
ibm_service_instance_id=credentials['从服务凭证描述中得到'],
ibm_auth_endpoint=credentials['s3.eu-gb.cloud-object-storage.appdomain.cloud'],//因为我的地区是伦敦
config=Config(signature_version='oauth'),
endpoint_url=credentials[' https://control.cloud-object-storage.cloud.ibm.com/v2/endpoints '])
尝试:
res=cos.upload_file(Filename='D:\ibm-cloud\get-started-python\abc.txt',
Bucket=credentials['cloud-college-bucket0'],Key=key)
例外为 e:
print(Exception, e)
别的:
print('File Uploaded')