[](https://github.com/DataShades/file-keeper/actions/workflows/test.yml)
# file-keeper
Abstraction layer for reading, writing and managing file-like objects.
The package implements drivers for a number of storage types(local filesystem,
redis, AWS S3, etc.) and defines a set of tools to simplify building your own
drivers for storage you are using.
Read the [documentation](https://datashades.github.io/file-keeper/) for a full
user guide.
## Usage
Initialize storage pointing to `/tmp/example` folder:
```python
import os
from file_keeper import make_storage
storage = make_storage("sandbox", {
"type": "file_keeper:fs",
"path": "/tmp/example",
# this option creates the folder if it does not exist.
# Without it storage raises an error if folder is missing
"create_path": True,
})
assert os.path.isdir("/tmp/example")
```
Upload file into the storage initialized in the previous step and play with it
a bit:
```python
from file_keeper import make_upload
upload = make_upload(b"hello world")
# save the data and verify its presence in the system
result = storage.upload("hello.txt", upload)
assert result.size == 11
assert os.path.isfile("/tmp/example/hello.txt")
# change location of the file
moved_result = storage.move("moved-hello.txt", result, storage)
assert not os.path.exists("/tmp/example/hello.txt")
assert os.path.isfile("/tmp/example/moved-hello.txt")
# read the file
assert storage.content(moved_result) == b"hello world"
# remove the file
storage.remove(moved_result)
assert not os.path.exists("/tmp/example/moved-hello.txt")
```
## Development
Install `dev` extras:
```sh
pip install -e '.[dev]'
```
Run unittests:
```sh
pytest
```
Run typecheck:
```sh
pyright
```
## License
[AGPL](https://www.gnu.org/licenses/agpl-3.0.en.html)
Raw data
{
"_id": null,
"home_page": null,
"name": "file-keeper",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "DataShades <datashades@linkdigital.com.au>",
"keywords": "file-management, cloud, filesystem, DAL",
"author": null,
"author_email": "DataShades <datashades@linkdigital.com.au>, Sergey Motornyuk <sergey.motornyuk@linkdigital.com.au>",
"download_url": "https://files.pythonhosted.org/packages/48/b7/db3cc6e0677f904ba6b35afc9d58374904972c2ae9e46b9d031cacb596e2/file_keeper-0.0.10.tar.gz",
"platform": null,
"description": "[](https://github.com/DataShades/file-keeper/actions/workflows/test.yml)\n\n# file-keeper\n\nAbstraction layer for reading, writing and managing file-like objects.\n\nThe package implements drivers for a number of storage types(local filesystem,\nredis, AWS S3, etc.) and defines a set of tools to simplify building your own\ndrivers for storage you are using.\n\nRead the [documentation](https://datashades.github.io/file-keeper/) for a full\nuser guide.\n\n\n## Usage\n\nInitialize storage pointing to `/tmp/example` folder:\n\n```python\nimport os\nfrom file_keeper import make_storage\n\nstorage = make_storage(\"sandbox\", {\n \"type\": \"file_keeper:fs\",\n \"path\": \"/tmp/example\",\n # this option creates the folder if it does not exist.\n # Without it storage raises an error if folder is missing\n \"create_path\": True,\n})\nassert os.path.isdir(\"/tmp/example\")\n```\n\nUpload file into the storage initialized in the previous step and play with it\na bit:\n\n```python\nfrom file_keeper import make_upload\nupload = make_upload(b\"hello world\")\n\n# save the data and verify its presence in the system\nresult = storage.upload(\"hello.txt\", upload)\nassert result.size == 11\nassert os.path.isfile(\"/tmp/example/hello.txt\")\n\n# change location of the file\nmoved_result = storage.move(\"moved-hello.txt\", result, storage)\nassert not os.path.exists(\"/tmp/example/hello.txt\")\nassert os.path.isfile(\"/tmp/example/moved-hello.txt\")\n\n# read the file\nassert storage.content(moved_result) == b\"hello world\"\n\n# remove the file\nstorage.remove(moved_result)\nassert not os.path.exists(\"/tmp/example/moved-hello.txt\")\n```\n\n## Development\n\nInstall `dev` extras:\n\n```sh\npip install -e '.[dev]'\n```\n\nRun unittests:\n```sh\npytest\n```\n\nRun typecheck:\n```sh\npyright\n```\n\n\n## License\n\n[AGPL](https://www.gnu.org/licenses/agpl-3.0.en.html)\n",
"bugtrack_url": null,
"license": "AGPL-3.0",
"summary": "Abstraction level for object storages.",
"version": "0.0.10",
"project_urls": {
"Homepage": "https://github.com/DataShades/file-keeper"
},
"split_keywords": [
"file-management",
" cloud",
" filesystem",
" dal"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "3d266278196d54499675d23834d402be3a61f70cdac07b3d794fc47aa78822a8",
"md5": "4c61208aabb6a140c97e6bda2e0c37ab",
"sha256": "c3bb8693348154c9c626a7859511cf7a53abae4754ac06623acff9b9a488919a"
},
"downloads": -1,
"filename": "file_keeper-0.0.10-py3-none-any.whl",
"has_sig": false,
"md5_digest": "4c61208aabb6a140c97e6bda2e0c37ab",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 37301,
"upload_time": "2025-07-13T18:32:25",
"upload_time_iso_8601": "2025-07-13T18:32:25.901913Z",
"url": "https://files.pythonhosted.org/packages/3d/26/6278196d54499675d23834d402be3a61f70cdac07b3d794fc47aa78822a8/file_keeper-0.0.10-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "48b7db3cc6e0677f904ba6b35afc9d58374904972c2ae9e46b9d031cacb596e2",
"md5": "a6e8419846735c969c12f66a2d0f72b6",
"sha256": "3fb806ed61a128fbf5816ab1be1126bae43cd2919fc968a41b60ecfdf4aad333"
},
"downloads": -1,
"filename": "file_keeper-0.0.10.tar.gz",
"has_sig": false,
"md5_digest": "a6e8419846735c969c12f66a2d0f72b6",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 29777,
"upload_time": "2025-07-13T18:32:27",
"upload_time_iso_8601": "2025-07-13T18:32:27.613210Z",
"url": "https://files.pythonhosted.org/packages/48/b7/db3cc6e0677f904ba6b35afc9d58374904972c2ae9e46b9d031cacb596e2/file_keeper-0.0.10.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-13 18:32:27",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "DataShades",
"github_project": "file-keeper",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "file-keeper"
}