<p align="center">
<a href="https://pypi.org/project/fstorage">
<img src="https://raw.githubusercontent.com/ispaneli/fstorage/master/docs/img/logo.png" alt="FStorage">
</a>
</p>
<p align="center">
<em>Fstorage, Secure file storage, SYNC/ASYNC clients, easy to learn, fast to code.</em>
</p>
<p align="center">
<a href="https://pypi.org/project/fstorage" target="_blank">
<img src="https://img.shields.io/pypi/v/fstorage?color=%2334D058&label=pypi%20package" alt="Package version">
</a>
<a href="https://pypi.org/project/fstorage" target="_blank">
<img src="https://img.shields.io/pypi/pyversions/fstorage.svg?color=%2334D058" alt="Supported Python versions">
</a>
<a href="https://pypi.org/project/fstorage" target="_blank">
<img src="https://static.pepy.tech/personalized-badge/fstorage?period=total&units=none&left_color=grey&right_color=brightgreen&left_text=Downloads" alt="Total downloads">
</a>
</p>
---
**Source Code**:
<a href="https://github.com/ispaneli/fstorage" target="_blank">
https://github.com/ispaneli/fstorage
</a>
---
**FStorage** is a simple asynchronous secure file storage for microservices.
It is implemented on the **<a href="https://pypi.org/project/fastapi/" class="external-link" target="_blank">FastAPI</a>** web framework.
To run the file storage, you need:
* **<a href="https://www.postgresql.org/" class="external-link" target="_blank">PostgreSQL</a>**
**WARNING**: With the usual installation of `pip install fstorage`, the requirements are not installed (for more info, see [How to install](#how-to-install-with-requirements))!
---
## How to install with requirements
To deploy the FStorage on the **server**:
```bash
pip install 'fstorage[server]'
```
To use **synchronous client**:
```bash
pip install 'fstorage[sync_client]'
```
To use **asynchronous client**:
```bash
pip install 'fstorage[async_client]'
```
---
## How to deploy storage
Configure virtual environment variables in terminal:
```bash
export POSTGRESQL_URL="postgresql+asyncpg://<db_username>:<db_password>@<db_host>:<db_port>/<db_name>"
export STORAGE_PATH="/Users/<local_username>/.fstorage/storage"
```
Configure **logging.ini**:
```ini
[loggers]
keys=root
[handlers]
keys=logfile, logconsole
[formatters]
keys=logformatter
[logger_root]
level=INFO
handlers=logfile, logconsole
[formatter_logformatter]
format=[%(asctime)s.%(msecs)03d] %(levelname)s [%(thread)d] - %(message)s
[handler_logfile]
class=handlers.RotatingFileHandler
level=INFO
args=('/Users/<local_username>/.fstorage/logfile.log', 'a')
formatter=logformatter
[handler_logconsole]
class=handlers.logging.StreamHandler
level=INFO
args=()
formatter=logformatter
```
Run this code:
```python
import os
from fstorage.server import storage_run
if __name__ == '__main__':
storage_run(
storage_path=os.getenv('STORAGE_PATH'),
log_config_path="logging.ini",
db_async_url=os.getenv('POSTGRESQL_URL'),
db_echo=True,
db_future=True,
db_drop_all=False,
host='127.0.0.1',
port=8_000,
reload=False,
workers_num=1
)
```
---
## How to use synchronous client
```python
from fstorage.client.synch.client import SyncClient
if __name__ == '__main__':
client = SyncClient("http://127.0.0.1:8000")
upload_response: dict = client.upload(open("example.file", 'rb'))
print(upload_response)
# {'id': "<file_id>"}
get_response: dict = client.get(upload_response['id'])
print(get_response)
# {'filename': "example.file", 'bytes': '<data_as_bytes>'}
client.delete(upload_response['id'])
try:
client.get(upload_response['id'])
except FileExistsError as error:
print(error)
# "The file with this ID doesn't exist."
try:
client.delete(upload_response['id'])
except FileExistsError as error:
print(error)
# "The file with this ID doesn't exist."
```
---
## How to use asynchronous client
```python
import asyncio
from fstorage.client.asynch.client import AsyncClient
async def example():
client = AsyncClient("http://127.0.0.1:8000")
upload_response: dict = await client.upload(open("example.file", 'rb'))
print(upload_response)
# {'id': "<file_id>"}
get_response: dict = await client.get(upload_response['id'])
print(get_response)
# {'filename': "example.file", 'bytes': '<data_as_bytes>'}
await client.delete(upload_response['id'])
try:
await client.get(upload_response['id'])
except FileExistsError as error:
print(error)
# "The file with this ID doesn't exist."
try:
await client.delete(upload_response['id'])
except FileExistsError as error:
print(error)
# "The file with this ID doesn't exist."
if __name__ == '__main__':
asyncio.run(example())
```
---
## License
This project is licensed under the terms of the [MIT license](https://github.com/ispaneli/fstorage/blob/master/LICENSE).
Raw data
{
"_id": null,
"home_page": "https://github.com/ispaneli/fstorage",
"name": "fstorage",
"maintainer": "",
"docs_url": null,
"requires_python": "<4,>=3.8",
"maintainer_email": "",
"keywords": "file,files,storage,security,sync,synch,async,asynch,server,client,fastapi,aiohttp,requests",
"author": "Ilya Antonov",
"author_email": "ispanelki@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/6c/50/308b4b476438b878d44769143e76ee391d02a5f6fc388efbd1b4a28ce7a9/fstorage-0.0.3.tar.gz",
"platform": null,
"description": "<p align=\"center\">\n <a href=\"https://pypi.org/project/fstorage\">\n <img src=\"https://raw.githubusercontent.com/ispaneli/fstorage/master/docs/img/logo.png\" alt=\"FStorage\">\n </a>\n</p>\n<p align=\"center\">\n <em>Fstorage, Secure file storage, SYNC/ASYNC clients, easy to learn, fast to code.</em>\n</p>\n<p align=\"center\">\n <a href=\"https://pypi.org/project/fstorage\" target=\"_blank\">\n <img src=\"https://img.shields.io/pypi/v/fstorage?color=%2334D058&label=pypi%20package\" alt=\"Package version\">\n </a>\n <a href=\"https://pypi.org/project/fstorage\" target=\"_blank\">\n <img src=\"https://img.shields.io/pypi/pyversions/fstorage.svg?color=%2334D058\" alt=\"Supported Python versions\">\n </a>\n <a href=\"https://pypi.org/project/fstorage\" target=\"_blank\">\n <img src=\"https://static.pepy.tech/personalized-badge/fstorage?period=total&units=none&left_color=grey&right_color=brightgreen&left_text=Downloads\" alt=\"Total downloads\">\n </a>\n</p>\n\n---\n\n**Source Code**:\n<a href=\"https://github.com/ispaneli/fstorage\" target=\"_blank\">\n https://github.com/ispaneli/fstorage\n</a>\n\n---\n\n**FStorage** is a simple asynchronous secure file storage for microservices.\n\nIt is implemented on the **<a href=\"https://pypi.org/project/fastapi/\" class=\"external-link\" target=\"_blank\">FastAPI</a>** web framework.\n\nTo run the file storage, you need:\n* **<a href=\"https://www.postgresql.org/\" class=\"external-link\" target=\"_blank\">PostgreSQL</a>**\n\n**WARNING**: With the usual installation of `pip install fstorage`, the requirements are not installed (for more info, see [How to install](#how-to-install-with-requirements))!\n\n---\n\n## How to install with requirements\n\nTo deploy the FStorage on the **server**:\n\n```bash\npip install 'fstorage[server]'\n```\n\nTo use **synchronous client**:\n\n```bash\npip install 'fstorage[sync_client]'\n```\n\nTo use **asynchronous client**:\n\n```bash\npip install 'fstorage[async_client]'\n```\n\n---\n\n## How to deploy storage\n\nConfigure virtual environment variables in terminal:\n\n```bash\nexport POSTGRESQL_URL=\"postgresql+asyncpg://<db_username>:<db_password>@<db_host>:<db_port>/<db_name>\"\nexport STORAGE_PATH=\"/Users/<local_username>/.fstorage/storage\"\n```\n\nConfigure **logging.ini**:\n\n```ini\n[loggers]\nkeys=root\n\n[handlers]\nkeys=logfile, logconsole\n\n[formatters]\nkeys=logformatter\n\n[logger_root]\nlevel=INFO\nhandlers=logfile, logconsole\n\n[formatter_logformatter]\nformat=[%(asctime)s.%(msecs)03d] %(levelname)s [%(thread)d] - %(message)s\n\n[handler_logfile]\nclass=handlers.RotatingFileHandler\nlevel=INFO\nargs=('/Users/<local_username>/.fstorage/logfile.log', 'a')\nformatter=logformatter\n\n[handler_logconsole]\nclass=handlers.logging.StreamHandler\nlevel=INFO\nargs=()\nformatter=logformatter\n```\n\nRun this code:\n\n```python\nimport os\n\nfrom fstorage.server import storage_run\n\n\nif __name__ == '__main__':\n storage_run(\n storage_path=os.getenv('STORAGE_PATH'),\n log_config_path=\"logging.ini\",\n \n db_async_url=os.getenv('POSTGRESQL_URL'),\n db_echo=True,\n db_future=True,\n db_drop_all=False,\n\n host='127.0.0.1',\n port=8_000,\n reload=False,\n workers_num=1\n )\n```\n\n---\n\n## How to use synchronous client\n\n```python\nfrom fstorage.client.synch.client import SyncClient\n\n\nif __name__ == '__main__':\n client = SyncClient(\"http://127.0.0.1:8000\")\n\n upload_response: dict = client.upload(open(\"example.file\", 'rb'))\n print(upload_response)\n # {'id': \"<file_id>\"}\n\n get_response: dict = client.get(upload_response['id'])\n print(get_response)\n # {'filename': \"example.file\", 'bytes': '<data_as_bytes>'}\n\n client.delete(upload_response['id'])\n\n try:\n client.get(upload_response['id'])\n except FileExistsError as error:\n print(error)\n # \"The file with this ID doesn't exist.\"\n\n try:\n client.delete(upload_response['id'])\n except FileExistsError as error:\n print(error)\n # \"The file with this ID doesn't exist.\"\n```\n\n---\n\n## How to use asynchronous client\n\n```python\nimport asyncio\n\nfrom fstorage.client.asynch.client import AsyncClient\n\n\nasync def example():\n client = AsyncClient(\"http://127.0.0.1:8000\")\n\n upload_response: dict = await client.upload(open(\"example.file\", 'rb'))\n print(upload_response)\n # {'id': \"<file_id>\"}\n\n get_response: dict = await client.get(upload_response['id'])\n print(get_response)\n # {'filename': \"example.file\", 'bytes': '<data_as_bytes>'}\n\n await client.delete(upload_response['id'])\n\n try:\n await client.get(upload_response['id'])\n except FileExistsError as error:\n print(error)\n # \"The file with this ID doesn't exist.\"\n\n try:\n await client.delete(upload_response['id'])\n except FileExistsError as error:\n print(error)\n # \"The file with this ID doesn't exist.\"\n\n\nif __name__ == '__main__':\n asyncio.run(example())\n```\n\n---\n\n## License\n\nThis project is licensed under the terms of the [MIT license](https://github.com/ispaneli/fstorage/blob/master/LICENSE).\n",
"bugtrack_url": null,
"license": "",
"summary": "Fstorage, Secure file storage, SYNC/ASYNC clients, easy to learn, fast to code.",
"version": "0.0.3",
"split_keywords": [
"file",
"files",
"storage",
"security",
"sync",
"synch",
"async",
"asynch",
"server",
"client",
"fastapi",
"aiohttp",
"requests"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f8d51b6073d4b3bb2fd8739e2badb66e4f5897d82a5ffc866499c5a81105b13a",
"md5": "1897ef59f57a919bb82c2eed74c06cc8",
"sha256": "f1b8dc9411f2deb94871ac7f8e861637085614a37bdc1dbc8f3ad2be7cd6d99d"
},
"downloads": -1,
"filename": "fstorage-0.0.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "1897ef59f57a919bb82c2eed74c06cc8",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4,>=3.8",
"size": 11958,
"upload_time": "2023-03-22T18:07:33",
"upload_time_iso_8601": "2023-03-22T18:07:33.563236Z",
"url": "https://files.pythonhosted.org/packages/f8/d5/1b6073d4b3bb2fd8739e2badb66e4f5897d82a5ffc866499c5a81105b13a/fstorage-0.0.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "6c50308b4b476438b878d44769143e76ee391d02a5f6fc388efbd1b4a28ce7a9",
"md5": "1ae0d8c0a67778f1adda09c970a075f8",
"sha256": "8c6618e22709ea7b48157fc42daae171e82cbbbd9a8239ea137918cad0b7c70d"
},
"downloads": -1,
"filename": "fstorage-0.0.3.tar.gz",
"has_sig": false,
"md5_digest": "1ae0d8c0a67778f1adda09c970a075f8",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4,>=3.8",
"size": 10962,
"upload_time": "2023-03-22T18:07:35",
"upload_time_iso_8601": "2023-03-22T18:07:35.764557Z",
"url": "https://files.pythonhosted.org/packages/6c/50/308b4b476438b878d44769143e76ee391d02a5f6fc388efbd1b4a28ce7a9/fstorage-0.0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-03-22 18:07:35",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "ispaneli",
"github_project": "fstorage",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "fstorage"
}