Skip to main content

This Module Upload and Host Any File Easy On Django

Project description

Django File Upload Handler

An Easy Way To Upload Files To Django

✨ Features

  • Upload Any File With Any Size In Any Format
  • Saves Files Secure and Denied Foreign Requests
  • Simple Import and Usage
  • Host Files Safely With Simple Key

📦 Install

$ pip3 install djfiler

🔨 Usage

# Import Django Filer
from djfiler import djfiler

# Initial Django Filer
djs = djfiler.Filer('/dir/of/uploades', True)

''' djs can be any name you like '''

Handle Upload Files In Any Format

def home(request):
    if request.method == "POST":
        callback = djs.upload(file=request.FILES['file name uploaded'], name="Optional" )
        print(callback) # Its Returns {status:ok | fail,name: name of file ( Its Key Of File ),type: type of file }

Return Any File With A Simple Key (Key Is The String That We Return To You When Uploaded file)

urls.py

 path('images/<slug:key>', sendfile)

 ''' path name can be anything you like we just need the key parameters '''

views.py

def sendfile(request, key):
    callback = djs.find(key)
    if callback != None:
        data = json.loads(callback)
        if data['find']:
            with open(data['uri'], "rb") as f:
                return HttpResponse(f.read(), content_type='*/*')
        else:
            return HttpResponse('ERROR TO SEND FILE')
    else:
        return HttpResponse('File Not Found')

Thats All

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

djfiler-0.1-py3-none-any.whl (9.8 kB view hashes)

Uploaded Python 3

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