ceph中rgw对象etag的示例代码
发表于:2024-10-04 作者:千家信息网编辑
千家信息网最后更新 2024年10月04日,这篇文章将为大家详细讲解有关ceph中rgw对象etag的示例代码,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。import hashlibimport botoi
千家信息网最后更新 2024年10月04日ceph中rgw对象etag的示例代码
这篇文章将为大家详细讲解有关ceph中rgw对象etag的示例代码,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。
import hashlibimport botoimport tracebackfrom boto.s3.connection import S3Connectionclass ETagExample(object): def __init__(self): self.s3_bucket = "yuliyang6" self.s3_conn = boto.connect_s3( "admin", "admin", host="192.168.10.147", is_secure=False, port=8081, calling_format=boto.s3.connection.OrdinaryCallingFormat(), ) #Function to calculate the checksum of a local file def find_checksum(self, file_name): try: checksum = hashlib.md5(open(file_name).read()).hexdigest() return checksum except Exception, e: print "Exception occurred while calculating checksum :" + str(e) print traceback.print_exc() #Function to calculate the Etag of a file in S3 def find_etag(self, full_key_name): try: bucket = self.s3_conn.get_bucket(self.s3_bucket) key = bucket.get_key(full_key_name) s3_etag = key.etag.strip('"').strip("'") return s3_etag except Exception, e: print "Exception occurred while calculating S3 Etag : " + str(e) print traceback.print_exc()if __name__ == '__main__': test = ETagExample() print test.find_checksum('object1') print test.find_etag('object1')320c1c0f22dc91d94afe36a042ebc89dsend: 'HEAD /yuliyang6/ HTTP/1.1\r\nHost: 192.168.10.147:8081\r\nAccept-Encoding: identity\r\nDate: Sun, 06 Nov 2016 07:54:51 GMT\r\nContent-Length: 0\r\nAuthorization: AWS admin:P7eaeSj73/8dObIeJtIac/ZwXzA=\r\nUser-Agent: Boto/2.41.0 Python/2.7.9 Windows/7\r\n\r\n'reply: 'HTTP/1.1 200 OK\r\n'header: X-RGW-Object-Count: 1header: X-RGW-Bytes-Used: 847header: x-amz-request-id: tx0000000000000000004f6-00581ee1cb-857b-defaultheader: Content-Length: 0header: Date: Sun, 06 Nov 2016 07:54:51 GMTsend: 'HEAD /yuliyang2/ HTTP/1.1\r\nHost: 192.168.10.147:8081\r\nAccept-Encoding: identity\r\nDate: Sun, 06 Nov 2016 07:54:51 GMT\r\nContent-Length: 0\r\nAuthorization: AWS admin:FOtHjwG9XIHPaoBy8TT8QDB3y0I=\r\nUser-Agent: Boto/2.41.0 Python/2.7.9 Windows/7\r\n\r\n'reply: 'HTTP/1.1 200 OK\r\n'header: X-RGW-Object-Count: 4header: X-RGW-Bytes-Used: 104858452header: x-amz-request-id: tx0000000000000000004f7-00581ee1cb-857b-defaultheader: Content-Length: 0header: Date: Sun, 06 Nov 2016 07:54:51 GMTsend: 'HEAD /yuliyang2/object1 HTTP/1.1\r\nHost: 192.168.10.147:8081\r\nAccept-Encoding: identity\r\nDate: Sun, 06 Nov 2016 07:54:51 GMT\r\nContent-Length: 0\r\nAuthorization: AWS admin:KADu0hAVS1BVs3Y9zTIO7dRovCs=\r\nUser-Agent: Boto/2.41.0 Python/2.7.9 Windows/7\r\n\r\n'reply: 'HTTP/1.1 200 OK\r\n'header: Content-Length: 847header: Accept-Ranges: bytesheader: Last-Modified: Sun, 06 Nov 2016 07:54:12 GMTheader: ETag: "320c1c0f22dc91d94afe36a042ebc89d"header: x-amz-request-id: tx0000000000000000004f8-00581ee1cb-857b-defaultheader: Content-Type: binary/octet-streamheader: Date: Sun, 06 Nov 2016 07:54:51 GMT320c1c0f22dc91d94afe36a042ebc89d
[root@joke ceph-request]# ceph-request -c ceph-request.cfg -m head -r '/yuliyang2/object1' -v< HEAD /yuliyang2/object1 HTTP/1.1< Host: 192.168.10.147:8081< Connection: keep-alive< Accept-Encoding: gzip, deflate< Accept: */*< User-Agent: python-requests/2.11.1< date: Sun, 06 Nov 2016 07:54:28 GMT< Authorization: AWS admin:qCWFpvxlOfSERMeaV/sfVm0Wcek=< > HTTP/1.1 200 OK> Content-Length: 847> Accept-Ranges: bytes> Last-Modified: Sun, 06 Nov 2016 07:54:12 GMT> ETag: "320c1c0f22dc91d94afe36a042ebc89d"> x-amz-request-id: tx0000000000000000004f5-00581ee1b4-857b-default> Content-Type: binary/octet-stream> Date: Sun, 06 Nov 2016 07:54:28 GMT> Connection: Keep-Alive>
关于"ceph中rgw对象etag的示例代码"这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。
篇文章
代码
对象
示例
更多
不错
实用
内容
文章
知识
参考
帮助
有关
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
工业网络技术问题
网络安全事件有
三级网络技术题库及其答案
新吴区微型软件开发价格优惠
软件开发和模型开发
奉贤区水性网络技术价格查询
莱阳安卓软件开发外包公司
软件开发流体力分析
杜比的服务器安全连接怎么做
无法连接数据库怎么回事
网络安全证书能考公务员吗
商丘网络安全工程师待遇
文明重启有没有不抄家的服务器
学习计算机网络技术要用电脑吗
省局税务服务器总是卡
梓潼软件开发者在线咨询
哪个服务器能加速csgo
用友网络技术大佬
个性化软件开发共同合作
腾讯视频服务器有多少大
计算机软件和计算机网络技术
深圳市软件开发测试招聘
大型服务器为什么耗电
栖霞区智能化软件开发信息推荐
数据库安全特性包括什么作用
东城区大型软件开发规定
苍空物语为什么服务器没见了
秦美人一键端 找不到数据库
英雄连登录ae服务器
网络安全整改系统局缺少