File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 11# -*- coding=utf-8
22from qcloud_cos import CosConfig
33from qcloud_cos import CosS3Client
4+ from qcloud_cos import CosServiceError
5+ from qcloud_cos import CosClientError
46
57# 腾讯云COSV5Python SDK, 目前可以支持Python2.6与Python2.7
68
5557)
5658fp = response ['Body' ].get_raw_stream ()
5759print fp .read (2 )
60+
61+ # 文件下载 捕获异常
62+ try :
63+ response = client .get_object (
64+ Bucket = 'test04' ,
65+ Key = 'not_exist.txt' ,
66+ )
67+ fp = response ['Body' ].get_raw_stream ()
68+ print fp .read (2 )
69+ except CosServiceError as e :
70+ print e .get_origin_msg ()
71+ print e .get_digest_msg ()
72+ print e .get_status_code ()
73+ print e .get_error_code ()
74+ print e .get_error_msg ()
75+ print e .get_resource_location ()
76+ print e .get_trace_id ()
77+ print e .get_request_id ()
78+
You can’t perform that action at this time.
0 commit comments