Skip to main content

Apiqa user storage backend for django projects

Project description


This project aim is to provide user storage backend on minio for all apiqa django projects.


  • Add apiqa-storage to requirements.txt.
# Minio file storage
  • Add apiqa_storage to INSTALLED_APPS in settings file.
  • Add mixin ModelWithAttachmentsMixin to any model. Make and run migrations.
from apiqa_storage.models import ModelWithAttachmentsMixin

class UserFile(ModelWithAttachmentsMixin, ...):
  • Add serializer mixin at the beginning and add attachments, attachment_ids to fields.
from apiqa_storage.serializers import AttachmentsSerializerMixin

class ModelWithAttachmentsSerializer(AttachmentsSerializerMixin, ...):

    class Meta:
        fields = (..., 'attachments', 'attachment_ids')
  • Add download and upload file urls to urlpatterns.
from django.urls import path, include

urlpatterns = [
    path('attachments/', include('apiqa_storage.urls')),
  • Or add staff download file url to urlpatterns.
from django.urls import path, include

urlpatterns = [  # noqa
    path('attachments/', include('apiqa_storage.staff_urls')),
  • Add clean files task to celery beat config.
from celery.schedules import crontab
beat_schedule = {
    # apiqa-storage clean files
    'purge_attachments': {
        'task': 'apiqa_storage.tasks.purge_attachments',
        'schedule': crontab(hour=5)
  • Other settings

    • MINIO_STORAGE_MAX_FILE_SIZE: File size limit for upload, humanfriendly value. See Default 100M
    • MINIO_STORAGE_MAX_FILE_NAME_LEN: File name length limit. Use for database char limit. Default 100
    • MINIO_STORAGE_MAX_FILES_COUNT: Limit of files in one object. For example 5 files in ticket. None - is unlimited. Default None
    • MINIO_STORAGE_USE_HTTPS: Use https for connect to minio. Default False
    • MINIO_STORAGE_CLEAN_PERIOD: Delete files without related objects after N days. Default 30
  • Run test

pip install -r requirements.txt
pip install -r
docker-compose up
pytest --cov .

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

apiqa-storage-2.10.0.tar.gz (13.9 kB view hashes)

Uploaded source

Built Distribution

apiqa_storage-2.10.0-py3-none-any.whl (20.3 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page