Skip to main content

apiqa-storage

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

HowToUse

  • Add apiqa-storage to requirements.txt.
# Minio file storage
git+https://github.com/pik-software/apiqa-storage.git#egg=apiqa-storage
  • Add apiqa_storage to INSTALLED_APPS in settings file.
INSTALLED_APPS = [
    'django.contrib.admin',
    ...,
    'apiqa_storage'
]
  • 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)
    },
}
MINIO_STORAGE_ENDPOINT = 'minio:9000'
MINIO_STORAGE_ACCESS_KEY = ...
MINIO_STORAGE_SECRET_KEY = ...
MINIO_STORAGE_BUCKET_NAME = 'local-static'
  • Other settings

    • MINIO_STORAGE_MAX_FILE_SIZE: File size limit for upload, humanfriendly value. See https://humanfriendly.readthedocs.io/en/latest/readme.html#a-note-about-size-units. 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 requirements.dev.txt
docker-compose up
pytest --cov .

Metadata

Release files for apiqa-storage 2.10.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 apiqa-storage 2.10.0
File Size Uploaded Provenance Actions
apiqa-storage-2.10.0.tar.gz 13.9 kB Without provenance Details for apiqa-storage-2.10.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for apiqa-storage 2.10.0
File Interpreter ABI Platform Actions
apiqa_storage-2.10.0-py3-none-any.whl Python 3 none any Details for apiqa_storage-2.10.0-py3-none-any.whl

Total release size: 34.2 kB

Release files / apiqa-storage-2.10.0.tar.gz

Download URL apiqa-storage-2.10.0.tar.gz
Size 13.9 kB
Tags Source
SHA-256 checksum
How to use checksums
829ac284fc54d13eb4050d2031acfab69967bb6c89f8d338dfc1105f127693ce
BLAKE2b-256 checksum
How to use checksums
f8d9ce0c81bd5edd1b0882c37a9da21779fdff06b9018c27f8203eebaf7025b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.9.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.6

Release files / apiqa_storage-2.10.0-py3-none-any.whl

Download URL apiqa_storage-2.10.0-py3-none-any.whl
Size 20.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
298be156fb5ffcb4416ac7a66ba0e26b36966a8803b50c50f6c1331528256e4a
BLAKE2b-256 checksum
How to use checksums
e4c77d617e4d388bda5c7f2a086196cbaae2adb74bf66ede7de66df485004c54
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.9.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.6

Security for apiqa-storage 2.10.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