Flask extension that provides integration with Azure Storage
Project description
A Flask extension that provides integration with Azure Storage
Install
pip install Flask-Azure-Storage
Usage
Set the account credentials in your app.config:
AZURE_STORAGE_ACCOUNT_NAME = "your-account-name" AZURE_STORAGE_ACCOUNT_KEY = "your-account-key"
Initialize the extension:
from flask import Flask from flask.ext.azure_storage import FlaskAzureStorage app = Flask(__name__) azure_storage = FlaskAzureStorage(app)
Or, if you follow the Flask application factory pattern:
from flask import Flask from flask.ext.azure_storage import FlaskAzureStorage azure_storage = FlaskAzureStorage() def create_app(config): app = Flask(__name__) app.config.from_object(config) # initialize azure storage on the app within create_app() azure_storage.init_app(app)
From the azure_storage object you can now access any of the following classes:
Attribute |
Class |
---|---|
azure_storage.account |
azure.storage.cloudstorageaccount.CloudStorag eAccount |
azure_storage.block_blob _service |
azure.storage.blob.blockblobservice.BlockBlob Service |
azure_storage.page_blob_service |
azure.storage.blob.pageblobservice.PageBlobSe rvice |
azure_storage.append_blo b_service |
azure.storage.blob.appendblobservice.AppendBl obService |
azure_storage.queue_serv ice |
azure.storage.queue.queueservice.QueueService |
azure_storage.table_serv ice |
azure.storage.table.tableservice.TableService |
azure_storage.file_servi ce |
azure.storage.file.fileservice.FileService |
Examples
Create container
azure_storage.block_blob_service.create_container('container-name')
Delete container
azure_storage.block_blob_service.delete_container('container-name'
Upload a file
from azure.storage.blob import ContentSettings azure_storage.block_blob_service.create_blob_from_path(container_name='container-name', blob_name='uploaded-file-name', file_path='/path/to/your/file.png', content_settings=ContentSettings(content_type='image'))
Delete a file
azure_storage.block_blob_service.delete_blob('container-name', 'uploaded-file-name')
Check if file exists
azure_storage.block_blob_service.exists('container-name', 'uploaded-file-name')
Read more
There are plenty more things you can do. For more examples, check out the Azure Storage SDK for Python samples
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Hashes for Flask-Azure-Storage-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47de254e5afcb567feca2f0a6834aed43bfc7e5d4a28007cdaccee677b7b017b |
|
MD5 | 8073e08c213d8d093fece55cd893f45b |
|
BLAKE2b-256 | 06d4618bb39dc2ec62ecd1baee07f44805279d34cd89589ab25dc53f0defebe6 |