Skip to main content

BlockFrame

alt text

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:

pip install BlockFrame

Usage

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

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.

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.

{
  "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.

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.

Metadata

Release files for BlockFrame 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for BlockFrame 1.1.0
File Size Uploaded Provenance Actions
BlockFrame-1.1.0.tar.gz 10.1 kB Without provenance Details for BlockFrame-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for BlockFrame 1.1.0
File Interpreter ABI Platform Actions
BlockFrame-1.1.0-py3-none-any.whl Python 3 none any Details for BlockFrame-1.1.0-py3-none-any.whl

Total release size: 23.3 kB

Release files / BlockFrame-1.1.0.tar.gz

Download URL BlockFrame-1.1.0.tar.gz
Size 10.1 kB
Tags Source
SHA-256 checksum
How to use checksums
6de89736f0bedecc0b37df1d3f6ecf87ea82d6c8d145a75266901b45d96e4b8f
BLAKE2b-256 checksum
How to use checksums
2f9ca6780c12ae363262895ee2e27d1242f27233409d0ced937af0176e500bcb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release files / BlockFrame-1.1.0-py3-none-any.whl

Download URL BlockFrame-1.1.0-py3-none-any.whl
Size 13.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b7f14bde4863e82c7cfa54ab4de222241297e126949e33d3fcef246fa539c58d
BLAKE2b-256 checksum
How to use checksums
ac8f6448b78471410d664c6803d2afbe4e913a9679ee137cbec8e031aabddc0a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Security for BlockFrame 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page