在Kiwix/OpenZIM项目中使用的Kiwix S3缓存包装器

kiwixstorage的Python项目详细描述


猕猴桃贮藏室

CodeFactorLicense: GPL v3PyPI version shields.io

S3存储的助手,来自URL+Wasabi的autoconf(wasabisys.com网站)额外费用

目标主要是从一个URL提供一个配置好的s3.client和s3.resource 用户可以将使用限制在这个范围内,并直接从那里使用boto3。在

为了简化常见的操作,还准备了一些附加的包装器。 另外,非S3、wasabi特有的特性也会直接暴露出来。在

使用

pip install kiwixstorage

连接

^{pr2}$

铲运机使用案例

online_url="https://xxx"fpath="/local/path.ext"# retrieve origin etagetag=requests.head(online_url,allow_redirects=True).headers.get("Etag")# check if we have that very same version in storeifs3.has_matching_object(key=url,etag=etag)# lastest version in our store, download from there (using progress output)s3.download_file(key=url,fpath=fpath,progress=True)else:# download the origin file using your regular toolsdownload_file(url,fpath)# upload it our storages3.upload_file(fpath=fpath,key=url)# now you have a local file of lastest version and the storage is up to date

其他用例

# create a bucketbucket=s3.create_bucket("bucket_name")# set auto-delete on buckets3.set_bucket_autodelete_after(nb_days=7)# allow public downloads from buckets3.allow_public_downloads_on()# upload a files3.upload_file(fpath,"some/path/file.img",meta={"ENCODER_VERSION":"v1"})# set autodelete on specific files3.set_object_autodelete_on(key,datetime.datetime.now())# download a files3.download_file(key,fpath)# get URL for external downloads3.get_download_url(key)

资源:

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
具有多用户OU和多访问CNs的java Spring LDAP身份验证   java分配的变量神秘地变为null   java比较两个表或文本文件,并用行号和列输出差异   java如何在同一构建目录中设置netbeans中的文件路径?   java如何在avro模式中定义byte[]和LocalDateTime?   java在多个活动和片段中使用相同的微调器。实施它的最佳方式是什么?   java使用OOPS扩展已编写的类   java如何在特定于文件的基础上禁用Eclipse中的编译器警告?   java将字符串转换为日期的格式不正确   Java文件从一台服务器复制到另一台服务器   java Jacksonal和JacksonApperasl的最新jar版本是什么?   java如何在使用selenium chrome web驱动程序时禁用chrome中的身份验证提示   java是什么。推荐人和推荐人。Eclipse工作区中的元数据以及它们是否应该在设备之间同步?   java我应该把sqlite db文件放在哪里,这样我的jar就可以访问它了?这对连接字符串有何影响?   java如何在选择单元格时设置JTable标题背景色   java Cassandra 2 Hector:复合行键上的范围切片查询返回空行   java方法注释继承   Python字节对象与java   java Android和从sqlite数据库加载listview