Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cinaaaa/djfiler
🗄️ Easy way to upload and host files in Django
https://github.com/cinaaaa/djfiler
django django-framework django-rest-framework django-uplaoding-module django-upload django-uploader host-files upload upload-easy upload-easy-django uploader uploadhandler
Last synced: about 1 month ago
JSON representation
🗄️ Easy way to upload and host files in Django
- Host: GitHub
- URL: https://github.com/cinaaaa/djfiler
- Owner: cinaaaa
- License: apache-2.0
- Created: 2019-08-08T04:03:50.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-05-24T03:20:28.000Z (over 4 years ago)
- Last Synced: 2024-09-27T16:40:57.431Z (about 2 months ago)
- Topics: django, django-framework, django-rest-framework, django-uplaoding-module, django-upload, django-uploader, host-files, upload, upload-easy, upload-easy-django, uploader, uploadhandler
- Language: Python
- Homepage: https://github.com/E-RROR/djfiler
- Size: 73.2 KB
- Stars: 5
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Django Filer
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
```bash
$ pip3 install djfiler
```## 🔨 Usage
```python
# Import Django Filer & json
import json
from djfiler import djfiler# Initial Django Filer
djs = djfiler.Filer('/dir/of/uploades', True)''' djs can be any name you like '''
```## 📤 Upload in Any Format
first create the function
urls.py
```python
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)
then in html file create simple form that send files with a name
```htmlSelect File to upload:
```
then files saves to directory you inital in the Class## 🎯 Host Files
urls.py
```python
path('images/', sendfile)
''' path name can be anything you like we just need the key parameters '''
```
views.py
```python
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')
```
file.html
```html
```
Thats All## 🗜️ Test Code
Simply Test code like this
```shell
$ git clone https://github.com/E-RROR/djfiler
$ cd djfiler
$ python3 test-djfiler.py
```