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 details)

Uploaded Python 3

File details

Details for the file djfiler-0.1-py3-none-any.whl.

File metadata

  • Download URL: djfiler-0.1-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.7.4

File hashes

Hashes for djfiler-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8c7f7cca3ad165101081b3d5d51cfa282996797042835b368edcdb6a2f9b072e
MD5 bc2bdda20d8b98b20f76a07c3b88fb80
BLAKE2b-256 a1f7a79c3c47a2ffab3cf116587bb692b423f47fd0e893f582b84006f037eeb7

See more details on using hashes here.

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