Kiwix S3 Cache wrapper to use within Kiwix/OpenZIM projects
Project description
kiwixstorage
helpers for S3 storage, autoconf from URL + Wasabi (wasabisys.com) extras
Goal is mainly to provide a configured s3.client and s3.resource from an URL Users could limit usage to this and use boto3 directly from there.
A few additional wrappers are in place to simplify common actions. Also, non-S3, wasabi-specific features are exposed directly.
Usage
pip install kiwixstorage
Connection
from kiwixstorage import KiwixStorage
url = "https://s3.us-east-1.wasabisys.com/?keyId=x&secretAccessKey=y&bucketName=z"
s3 = KiwixStorage(url)
# test credentials and ensure we can list buckets
if not s3.check_credentials(list_buckets=True, failsafe=True):
return # bad auth
Scraper use-case
online_url = "https://xxx"
fpath = "/local/path.ext"
# retrieve origin etag
etag = requests.head(online_url, allow_redirects=True).headers.get("Etag")
# check if we have that very same version in store
if s3.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 tools
download_file(url, fpath)
# upload it our storage
s3.upload_file(fpath=fpath, key=url)
# now you have a local file of lastest version and the storage is up to date
Other use cases
# create a bucket
bucket = s3.create_bucket("bucket_name")
# set auto-delete on bucket
s3.set_bucket_autodelete_after(nb_days=7)
# allow public downloads from bucket
s3.allow_public_downloads_on()
# upload a file
s3.upload_file(fpath, "some/path/file.img", meta={"ENCODER_VERSION": "v1"})
# set autodelete on specific file
s3.set_object_autodelete_on(key, datetime.datetime.now())
# download a file
s3.download_file(key, fpath)
# get URL for external download
s3.get_download_url(key)
Resources:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kiwixstorage-0.10.1.tar.gz.
File metadata
- Download URL: kiwixstorage-0.10.1.tar.gz
- Upload date:
- Size: 28.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a94dcfd1e5c3d9d86dee181d8f956dc51bd59cc78d5507d9817cebc46a046b8
|
|
| MD5 |
e9ea57059a7d104f75f0c7c46432a4c4
|
|
| BLAKE2b-256 |
5ab72519fd0cb13b845937576c6ccad8adf35347a379b107bc98951e6641e8f3
|
Provenance
The following attestation bundles were made for kiwixstorage-0.10.1.tar.gz:
Publisher:
Publish.yaml on openzim/python-storagelib
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kiwixstorage-0.10.1.tar.gz -
Subject digest:
6a94dcfd1e5c3d9d86dee181d8f956dc51bd59cc78d5507d9817cebc46a046b8 - Sigstore transparency entry: 686223627
- Sigstore integration time:
-
Permalink:
openzim/python-storagelib@8bea7963677c95053e6324e9c8e4996eb834f907 -
Branch / Tag:
refs/tags/v0.10.1 - Owner: https://github.com/openzim
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
Publish.yaml@8bea7963677c95053e6324e9c8e4996eb834f907 -
Trigger Event:
release
-
Statement type:
File details
Details for the file kiwixstorage-0.10.1-py3-none-any.whl.
File metadata
- Download URL: kiwixstorage-0.10.1-py3-none-any.whl
- Upload date:
- Size: 25.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b40f3d13ed4ff84aed04e26a984dfa4178a934f070e6e1f055d74bd68f4f704d
|
|
| MD5 |
f6a5ec1593f7207b2952e61d8e8cff1d
|
|
| BLAKE2b-256 |
aa5137e6d0acee38322eb759f80533050f85a47c3ff1bf5c39e980dec17bd279
|
Provenance
The following attestation bundles were made for kiwixstorage-0.10.1-py3-none-any.whl:
Publisher:
Publish.yaml on openzim/python-storagelib
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kiwixstorage-0.10.1-py3-none-any.whl -
Subject digest:
b40f3d13ed4ff84aed04e26a984dfa4178a934f070e6e1f055d74bd68f4f704d - Sigstore transparency entry: 686223633
- Sigstore integration time:
-
Permalink:
openzim/python-storagelib@8bea7963677c95053e6324e9c8e4996eb834f907 -
Branch / Tag:
refs/tags/v0.10.1 - Owner: https://github.com/openzim
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
Publish.yaml@8bea7963677c95053e6324e9c8e4996eb834f907 -
Trigger Event:
release
-
Statement type: