A package, which provides easy usage for minio with flask
Project description
Flask minio factory
A package, which provides easy usage for minio with flask.
Via this package you can easily create this connection
- with directly creating a minio instance
- or by using the application factory pattern
Intallation
You can install the package from pip:
pip install flask-minio-factory
Usage
If you want to create a minio instance directly you can achieve it by:
from flask import Flask
from flask_minio import Minio
app = Flask(__name__)
minio_client = Minio(app)
If you want to create the client via the application factory, you are able to do that with:
from flask import Flask, send_file
from flask_minio import Minio
app = Flask(__name__)
minio = Minio()
minio.init_app(app)
If you have the client you can simply call the available methods on it:
@app.route("/img/<id_>")
def query_image(id_):
with NamedTemporaryFile(suffix="png") as file:
minio.fget_object("img", id_, file.name)
return send_file(file.name)
(an example code can be tested under /example
)
The following config variables are avialble in the flask config:
Variable | Description | Default |
---|---|---|
MINIO_URL | Hostname of a S3 service. | - |
MINIO_ACCESS_KEY | (Optional) Access key (aka user ID) of your account in S3 service. | - |
MINIO_SECRET_KEY | (Optional) Secret Key (aka password) of your account in S3 service. | - |
MINIO_SESSION_TOKEN | (Optional) Session token of your account in S3 service. | - |
MINIO_SECURE_CONNECTION | (Optional) Flag to indicate to use secure (TLS) connection to S3 service or not. | False |
MINIO_REGION | (Optional) Region name of buckets in S3 service. | - |
MINIO_HTTP_CLIENT | (Optional) Customized HTTP client. | - |
MINIO_CREDENTIALS | (Optional) Credentials of your account in S3 service. | - |
MINIO_BUCKETS | (Optional) A list of buckets, that should be created at startup | - |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for flask_minio_factory-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | fd8425bc2ad0724bfbbe7159d1326ca9849d9726fa6e95a804c135e09dfe27a7 |
|
MD5 | 82db67e3a04093e00c349f72af1cf683 |
|
BLAKE2b-256 | df04cfbc47530145d2fafb6d92fb429aadacc54d1efb4e6718e650a976ca0919 |
Close
Hashes for flask_minio_factory-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a781b8e8391d887726178fb28f7461ce2aaac772833c74615a00f7ee98dba0bb |
|
MD5 | 0d559b484c879bb5e6ea833a4fc5725a |
|
BLAKE2b-256 | d2d0ab0e96beff84d0d861acfb64c1450018a1b92d6f6337afc103ca75e9a729 |