Metadata-Version: 2.4
Name: kiwix-uploader
Version: 1.7.1
Summary: SCP/SFTP helper for Kiwix, openZIM and offspot uploads to our dropbox
License-Expression: GPL-3.0-or-later
License-File: LICENSE
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Operating System :: POSIX
Requires-Dist: kiwixstorage==0.10.1
Requires-Dist: humanfriendly==10.0
Requires-Dist: pyright==1.1.408 ; extra == 'check'
Requires-Dist: ipython==9.11.0 ; extra == 'dev'
Requires-Dist: kiwix-uploader[scripts] ; extra == 'dev'
Requires-Dist: kiwix-uploader[lint] ; extra == 'dev'
Requires-Dist: kiwix-uploader[test] ; extra == 'dev'
Requires-Dist: kiwix-uploader[check] ; extra == 'dev'
Requires-Dist: ruff==0.15.6 ; extra == 'lint'
Requires-Dist: rust-just==1.48.0 ; extra == 'scripts'
Requires-Dist: pytest==9.0.2 ; extra == 'test'
Requires-Dist: coverage==7.13.5 ; extra == 'test'
Requires-Python: >=3.13
Project-URL: Homepage, https://github.com/kiwix/uploader
Project-URL: Donate, https://donate.kiwix.org/
Provides-Extra: check
Provides-Extra: dev
Provides-Extra: lint
Provides-Extra: scripts
Provides-Extra: test
Description-Content-Type: text/markdown

uploader
===

Dedicated container/script to upload files to openzim/kiwix warehouses

Files are uploaded via SFTP or SCP using OpenSSH and (pubkey authentication).
Files are uploaded to S3 assuming `bucketName`, `keyId` and `secretAccessKey` in query string.


## Usage

* Specify file to upload with `--file`.
* Mount the RSA private key onto `/etc/ssh/keys/id_rsa` or use `--private_key`
* Use an `scp://`, `sftp://`, `s3://` URLs to specify target.
* Specify a full path (with filename) to upload to a specific name or end with a `/` for uploading inside a folder

``` sh
docker run \
    -v ~/.ssh/id_rsa:/etc/ssh/keys/id_rsa:ro \
    -v /path/:/path:rw \
    ghcr.io/openzim/uploader \
    uploader \
    --file /path/my_file.zim \
    --upload-uri sftp://uploader@warehouse.farm.openzim.org/zim/ \
    --upload-uri "s3://s3.us-west-1.wasabisys.com/?bucketName=my-bucket&keyId=my-key&secretAccessKey=my-secret" \
    --move \
    --delete
```

### Parameters

* `--username`: if your URI has no username, you can specify it here.
* `--move`: upload to a temporary filename (`<fname>.tmp`) and rename it upon completion. Note that SCP is not able to do it so it uploads an `<fname>.complete` file upon completion instead.
* `--delete`: delete source file once uploaded successfuly.
* `--compress`: enable transfer compression.
* `--bandwidth`: enable bandwidth limit. Set it in Kbps.
* `--cipher`: change default cipher (`aes128-ctr`).
* `--resume`: resume partially uploaded file (SFTP only)

### Python

[![PyPI version shields.io](https://img.shields.io/pypi/v/kiwix_uploader)](https://pypi.org/project/kiwix_uploader/)

```sh
pip3 install kiwix_uploader[all]
uploader --help
```

```py
from kiwix_uploader import check_and_upload_file

check_and_upload_file(
    src_path="/path/my_file.zim",
    upload_uri="sftp://uploader@warehouse.farm.openzim.org/zim/",
    private_key="~/.ssh/id_rsa",
)
```

_Note_: `check_and_upload_file` returns an unix-like returncode (`0` on success)


```py
from kiwix_uploader import multi_file_upload

multi_file_upload(
    src_path="/path/my_file.zim",
    upload_uris=["sftp://uploader@warehouse.farm.openzim.org/zim/"],
    private_key="~/.ssh/id_rsa",
)
```

_Note_: `multi_file_upload` returns an `UploadResults` (see `upload` module)

```py
remove_file_retrying(
    upload_url="sftp://uploader@warehouse.farm.openzim.org/zim/my_file.zim",
    private_key=Path("~/.ssh/id_ed25519").expanduser()
)
```
