BlockFrame


NameBlockFrame JSON
Version 1.1.0 PyPI version JSON
download
home_pagehttps://github.com/Wizock/BlockFrame/
SummaryFile Chunking Library to work as a data-store solution alongside webapps and software.
upload_time2023-06-24 08:31:15
maintainer
docs_urlNone
authorRohaan Ahmed
requires_python>=3.6
license
keywords file chunking chunker sqlalchemy config data-store webapps software
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # BlockFrame

![alt text](https://i.imgur.com/GGHdpCe.png)

BlockFrame is a file chunking library designed to work as a data-store solution alongside web apps and software. It provides a simple and flexible way to store large files by breaking them into smaller chunks that can be easily managed and retrieved.

## Features

- Chunk files into smaller pieces of fixed or variable size
- Store chunks in a database or on disk, depending on your storage needs
- Fetch and reassemble original files from their chunks
- Highly configurable and customizable to suit specific needs
- Built with modern Python libraries like SQLAlchemy and cryptography for fast and secure file storage and retrieval
- Comprehensive documentation and tests to ensure reliability and correctness

## Installation

You can install BlockFrame using pip:

```sh
pip install BlockFrame
```

## Usage

Here's an example of how to use BlockFrame to chunk and store a file:

```py
import pathlib

from BlockFrame import block_frame

# initialize BlockFrame
config_path = pathlib.Path("./config.json").absolute()
block_frame = block_frame.BlockFrame(config_path, option="generic")


# chunking
block_frame.chunker.target(file_name="image.jpg", size=5)

block_frame.chunker.generic_chunking()


# fetcher
block_frame.fetcher.target("image.jpg")

block_frame.fetcher.fetch()
```

# Collaboration Tips

- If you encounter any issues or have suggestions for improvement, please open an issue on GitHub.
- Pull requests are welcome! Please ensure that your code adheres to the project's coding standards and that tests are passing before submitting a pull request.
- If you want to contribute but don't know where to start, please check the project's issues page or open-source guide for guidance.

# Different Ways to Use the Code

## Modifying Chunking Algorithm

You can modify the BlockFrame class to use different chunking algorithms. For example, you can use a sliding window algorithm to chunk files into smaller pieces.

```py
class BlockFrame(
    config: str,
    option: Literal['generic', 'time', 'secure']
)

```

3 very useful chunking algorithms are provided by default:

## Modifying Storage Options

You can modify the storage options used in the BlockFrame class by modifying the database configuration defined in the config.json file. By default, BlockFrame uses SQLite to store chunks in a database. However, you can modify the uri field in the database section of the configuration file to use a different database management system, such as MongoDB.

```json
{
  "database": {
    "uri": "mongodb://localhost:27017/",
    "name": "my_database"
  }
}
```

## Useable with context managers

Using a context manager with BlockFrame makes it easy to properly manage and clean up resources after use. The context manager takes care of initializing and tearing down the necessary resources like the chunker, fetcher, and database.

With the with statement, you can create a block of code where the BlockFrame object is instantiated and used. When the block is exited, the context manager's **exit** method is called to ensure that the resources are properly cleaned up.

In the example provided, the chunker object is used to target the file image.jpg and set a chunk size of 5. The generic_chunking method is then called to generate the chunks for the file. The fetcher object is used to target the same file and fetch the previously generated chunks.

Using a context manager ensures that all necessary resources are properly initialized and cleaned up, even if an error occurs during execution.

```py
import pathlib
from BlockFrame import block_frame
from BlockFrame.database_service.defaultmodel import DefaultChunkModel

config_path = pathlib.Path("./config.json").absolute()

with block_frame.BlockFrame(config_path, option="generic") as bf:
    bf.chunker.target("image.jpg", size=5)
    bf.chunker.generic_chunking()
    bf.fetcher.target("image.jpg")
    bf.fetcher.fetch()
```

I hope this helps! Let me know if you have any further questions.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Wizock/BlockFrame/",
    "name": "BlockFrame",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "file chunking,chunker,sqlalchemy,config,data-store,webapps,software",
    "author": "Rohaan Ahmed",
    "author_email": "silent.death3500@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/2f/9c/a6780c12ae363262895ee2e27d1242f27233409d0ced937af0176e500bcb/BlockFrame-1.1.0.tar.gz",
    "platform": null,
    "description": "# BlockFrame\r\n\r\n![alt text](https://i.imgur.com/GGHdpCe.png)\r\n\r\nBlockFrame is a file chunking library designed to work as a data-store solution alongside web apps and software. It provides a simple and flexible way to store large files by breaking them into smaller chunks that can be easily managed and retrieved.\r\n\r\n## Features\r\n\r\n- Chunk files into smaller pieces of fixed or variable size\r\n- Store chunks in a database or on disk, depending on your storage needs\r\n- Fetch and reassemble original files from their chunks\r\n- Highly configurable and customizable to suit specific needs\r\n- Built with modern Python libraries like SQLAlchemy and cryptography for fast and secure file storage and retrieval\r\n- Comprehensive documentation and tests to ensure reliability and correctness\r\n\r\n## Installation\r\n\r\nYou can install BlockFrame using pip:\r\n\r\n```sh\r\npip install BlockFrame\r\n```\r\n\r\n## Usage\r\n\r\nHere's an example of how to use BlockFrame to chunk and store a file:\r\n\r\n```py\r\nimport pathlib\r\n\r\nfrom BlockFrame import block_frame\r\n\r\n# initialize BlockFrame\r\nconfig_path = pathlib.Path(\"./config.json\").absolute()\r\nblock_frame = block_frame.BlockFrame(config_path, option=\"generic\")\r\n\r\n\r\n# chunking\r\nblock_frame.chunker.target(file_name=\"image.jpg\", size=5)\r\n\r\nblock_frame.chunker.generic_chunking()\r\n\r\n\r\n# fetcher\r\nblock_frame.fetcher.target(\"image.jpg\")\r\n\r\nblock_frame.fetcher.fetch()\r\n```\r\n\r\n# Collaboration Tips\r\n\r\n- If you encounter any issues or have suggestions for improvement, please open an issue on GitHub.\r\n- Pull requests are welcome! Please ensure that your code adheres to the project's coding standards and that tests are passing before submitting a pull request.\r\n- If you want to contribute but don't know where to start, please check the project's issues page or open-source guide for guidance.\r\n\r\n# Different Ways to Use the Code\r\n\r\n## Modifying Chunking Algorithm\r\n\r\nYou can modify the BlockFrame class to use different chunking algorithms. For example, you can use a sliding window algorithm to chunk files into smaller pieces.\r\n\r\n```py\r\nclass BlockFrame(\r\n    config: str,\r\n    option: Literal['generic', 'time', 'secure']\r\n)\r\n\r\n```\r\n\r\n3 very useful chunking algorithms are provided by default:\r\n\r\n## Modifying Storage Options\r\n\r\nYou can modify the storage options used in the BlockFrame class by modifying the database configuration defined in the config.json file. By default, BlockFrame uses SQLite to store chunks in a database. However, you can modify the uri field in the database section of the configuration file to use a different database management system, such as MongoDB.\r\n\r\n```json\r\n{\r\n  \"database\": {\r\n    \"uri\": \"mongodb://localhost:27017/\",\r\n    \"name\": \"my_database\"\r\n  }\r\n}\r\n```\r\n\r\n## Useable with context managers\r\n\r\nUsing a context manager with BlockFrame makes it easy to properly manage and clean up resources after use. The context manager takes care of initializing and tearing down the necessary resources like the chunker, fetcher, and database.\r\n\r\nWith the with statement, you can create a block of code where the BlockFrame object is instantiated and used. When the block is exited, the context manager's **exit** method is called to ensure that the resources are properly cleaned up.\r\n\r\nIn the example provided, the chunker object is used to target the file image.jpg and set a chunk size of 5. The generic_chunking method is then called to generate the chunks for the file. The fetcher object is used to target the same file and fetch the previously generated chunks.\r\n\r\nUsing a context manager ensures that all necessary resources are properly initialized and cleaned up, even if an error occurs during execution.\r\n\r\n```py\r\nimport pathlib\r\nfrom BlockFrame import block_frame\r\nfrom BlockFrame.database_service.defaultmodel import DefaultChunkModel\r\n\r\nconfig_path = pathlib.Path(\"./config.json\").absolute()\r\n\r\nwith block_frame.BlockFrame(config_path, option=\"generic\") as bf:\r\n    bf.chunker.target(\"image.jpg\", size=5)\r\n    bf.chunker.generic_chunking()\r\n    bf.fetcher.target(\"image.jpg\")\r\n    bf.fetcher.fetch()\r\n```\r\n\r\nI hope this helps! Let me know if you have any further questions.\r\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "File Chunking Library to work as a data-store solution alongside webapps and software.",
    "version": "1.1.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/Wizock/BlockFrame/issues",
        "Documentation": "https://blockframe.readthedocs.io/",
        "Homepage": "https://github.com/Wizock/BlockFrame/",
        "Source Code": "https://github.com/Wizock/BlockFrame/"
    },
    "split_keywords": [
        "file chunking",
        "chunker",
        "sqlalchemy",
        "config",
        "data-store",
        "webapps",
        "software"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ac8f6448b78471410d664c6803d2afbe4e913a9679ee137cbec8e031aabddc0a",
                "md5": "a425d92b67bf1cf2c500198b89d43f26",
                "sha256": "b7f14bde4863e82c7cfa54ab4de222241297e126949e33d3fcef246fa539c58d"
            },
            "downloads": -1,
            "filename": "BlockFrame-1.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a425d92b67bf1cf2c500198b89d43f26",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 13183,
            "upload_time": "2023-06-24T08:31:13",
            "upload_time_iso_8601": "2023-06-24T08:31:13.431197Z",
            "url": "https://files.pythonhosted.org/packages/ac/8f/6448b78471410d664c6803d2afbe4e913a9679ee137cbec8e031aabddc0a/BlockFrame-1.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2f9ca6780c12ae363262895ee2e27d1242f27233409d0ced937af0176e500bcb",
                "md5": "b9bb61228002eeeb41dbbb670efb79e0",
                "sha256": "6de89736f0bedecc0b37df1d3f6ecf87ea82d6c8d145a75266901b45d96e4b8f"
            },
            "downloads": -1,
            "filename": "BlockFrame-1.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "b9bb61228002eeeb41dbbb670efb79e0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 10076,
            "upload_time": "2023-06-24T08:31:15",
            "upload_time_iso_8601": "2023-06-24T08:31:15.149289Z",
            "url": "https://files.pythonhosted.org/packages/2f/9c/a6780c12ae363262895ee2e27d1242f27233409d0ced937af0176e500bcb/BlockFrame-1.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-24 08:31:15",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Wizock",
    "github_project": "BlockFrame",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "blockframe"
}
        
Elapsed time: 0.09942s