Skip to main content

Bulletproof attachment serving for Django Rest Framework.

Project description

Yediemin

A package for bulletproof attachment serving in Django Rest Framework.

Getting Started

Requirements

  • Nginx
  • Django Rest Framework
  • Session Authentication
  • Django Storages (S3)

Installation Steps

  1. Install package from PyPi.
pip install yediemin
  1. Add the view to urls.py
from yediemin import YedieminView

urlpatterns = [
    re_path(r'^yediemin/(?P<file_name>\S+)/$', YedieminView.as_view(), name='yediemin'),
]
  1. Configure Nginx. Place the configuration below under your server.
location /yediemin-files/ {
            internal;
            resolver 8.8.8.8;
            set $redirect_uri "$upstream_http_redirect_uri";

            proxy_buffering off;
            proxy_pass $redirect_uri;
}
  1. Use YedieminFileField in serializer for FileField.
from yediemin import YedieminFileField

class AttachmentSerializer(serializers.ModelSerializer):
    file = YedieminFileField()

    class Meta:
        model = Attachment
        fields = (
            "id",
            "file",
        )
  1. Use PrivateS3Boto3Storage for the field in models.py
from yediemin import PrivateS3Boto3Storage

class Attachment(models.Model):
    file = models.FileField(storage=PrivateS3Boto3Storage())
  1. Upload files to S3 with YedieminFileField. Yediemin requires presigned object url.

Settings

  • YEDIEMIN_HIDDEN_REDIRECT_PATH

Default: yediemin-files. It should be same with location in nginx configuration.

  • YEDIEMIN_AUTHENTICATION_CLASSES

Default: [rest_framework.authentication.SessionAuthentication]

  • YEDIEMIN_EXPIRE_IN

Default: 604800 seconds which is 1 week. This is the maximum limit provided by AWS. Using Query Parameters

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

yediemin-0.2.0.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yediemin-0.2.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file yediemin-0.2.0.tar.gz.

File metadata

  • Download URL: yediemin-0.2.0.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/2.7.16 Darwin/19.6.0

File hashes

Hashes for yediemin-0.2.0.tar.gz
Algorithm Hash digest
SHA256 c0b49696149916e32c307d03f7924800351c7f932b2d99ae0220df216e0f45b9
MD5 9c2bf1c975c9a6d44c149269d2c0b2f6
BLAKE2b-256 94e21a10ba6a712936e1c9c3029b487acd58344152fadf9b4bf1c4ff0e633645

See more details on using hashes here.

File details

Details for the file yediemin-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: yediemin-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/2.7.16 Darwin/19.6.0

File hashes

Hashes for yediemin-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aa757c011cbb62cf5b659179747a6e890b1bbe8381b58bc8cc541290488c6b6a
MD5 0aa22eef672470e0e1caefefe4d39dd5
BLAKE2b-256 b39258ec50501b50d8246b88e614544b961d0c6bc7885592de674240eed19f81

See more details on using hashes here.

Supported by

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