Giter Club home page Giter Club logo

djangofilestoragehandler's Introduction

DjangoFileStorageHandler

You can handle your storage files to MINIO, S3 or Local through Settings

About

This project is useful if you want to store and serve your file to different types of servers. You need to change a switch in settings.py and storage server will change their server in one go.

Installation

To install DjangoFileStoragesHandler, simply use pip:

$ pip install DjangoFileStoragesHandler

Documentation

You need to add few variables in your settings.py .

FILE_STORAGE_TO: This can be s3, local or Minio as per your need.

 FILE_STORAGE_TO = 's3' / 'local' / 'minio'

BUCKET_NAME: Enter the bucket name

 BUCKET_NAME = '*******' 

SUPPORTED_FORMAT_LIST

 SUPPORTED_FORMAT_LIST = ['.pdf', '.png', '.bmp', '.jpeg', '.jpg', '.doc', '.txt', '.docx', '.PDF', '.PNG', '.BMP',
                        '.JPEG', '.JPG', '.DOC', '.TXT', '.DOCX']

In case of AWS S3 you need to add below keys: AWS_ACCESS_KEY: Access key of AWS

 AWS_ACCESS_KEY = '************' 

AWS_SECRET_KEY: SECRET Access key of AWS

 AWS_SECRET_KEY = '************' 

AWS_REGION_NAME: Region name AWS

 AWS_REGION_NAME = '*******' 

In case of Minio: MINIO_ACCESS_KEY: Add Minio Access key.

 MINIO_ACCESS_KEY = '*******' 

MINIO_SECURE: Add MINIO SECURE key

 MINIO_SECURE = '*******' 

Example

>>>sh = storage_handler(path='/docs/', filename='uploadfilename',file_data=open('example.pdf','r')
>>>sh.upload_file()  # upload file to Server.
{'success': 1, 'message': 'successful'}
>>>sh.get_file_byte()  # gives file in byte format
{'success': 1, 'file':b'****************************....'}
>>>sh.get_file_base64() # gives file in base64 format
{'success': 1, 'message': 'successful', 'file': base64****************, 'file_extension':'***'}
>>>sh.download_file()  # Gives file in HTTPResponse.
>>>sh.delete()  #will delete you file
{'success': 1, 'message': 'successful'}

Found a Bug? Something Unsupported?

Please write me [email protected].

djangofilestoragehandler's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.