Skip to content

Commit 7e77340

Browse files
Update README.md
1 parent 7aeb5db commit 7e77340

File tree

1 file changed

+44
-2
lines changed

1 file changed

+44
-2
lines changed

README.md

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Features
1212
- Chunked uploads: optimizing large file transfers.
1313
- Prevent uploading existing files with MD5 checksum.
1414
- Easy to use any models.
15+
- Image optimizer, resizer, auto convert to webp (supported webp, png, jpg, jpeg).
16+
- Permissions.
1517

1618

1719
Quickstart
@@ -57,15 +59,24 @@ Change default config: `settings.py`
5759
DJANGO_CHUNK_FILE_UPLOAD = {
5860
"chunk_size": 1024 * 1024 * 2, # # custom chunk size upload (default: 2MB).
5961
"upload_to": "custom_folder/%Y/%m/%d", # custom upload folder.
60-
"is_metadata_storage": True, # save file metadata
62+
"is_metadata_storage": True, # save file metadata,
63+
"remove_file_on_update": True,
64+
"optimize": True,
6165
"js": (
6266
"https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js",
6367
"https://cdnjs.cloudflare.com/ajax/libs/spark-md5/3.0.2/spark-md5.min.js",
6468
"https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js",
6569
), # use cdn.
6670
"css": (
6771
"custom.css"
68-
) # custom css path.
72+
), # custom css path.
73+
"image_optimizer": {
74+
"quality": 82,
75+
"compress_level": 9,
76+
"max_width": 1024,
77+
"max_height": 720,
78+
"to_webp": True, # focus convert image to webp type.
79+
}
6980
}
7081

7182
```
@@ -107,11 +118,17 @@ views.py
107118

108119
```python
109120
from django_chunk_file_upload.views import ChunkedUploadView
121+
from django_chunk_file_upload.typed import File
122+
from django_chunk_file_upload.permissions import IsAuthenticated
110123
from .forms import YourForm
111124

112125

113126
class CustomChunkedUploadView(ChunkedUploadView):
114127
form_class = YourForm
128+
permission_classes = (IsAuthenticated,)
129+
# file_class = File # file class
130+
# optimize = True # default: True
131+
# remove_file_on_update = True # update image on admin page.
115132
# chunk_size = 1024 * 1024 * 2 # custom chunk size upload (default: 2MB).
116133
# upload_to = "custom_folder/%Y/%m/%d" # custom upload folder.
117134
# template_name = "custom_template.html" # custom template
@@ -139,4 +156,29 @@ urlpatterns = [
139156
]
140157
```
141158

159+
### Permissions
160+
```python
161+
from django_chunk_file_upload.permissions import AllowAny, IsAuthenticated, IsAdminUser, IsSuperUser
162+
```
163+
164+
### File Handlers
165+
```python
166+
from django_chunk_file_upload.typed import (
167+
ArchiveFile,
168+
AudioFile,
169+
BinaryFile,
170+
DocumentFile,
171+
File,
172+
FontFile,
173+
HyperTextFile,
174+
ImageFile,
175+
JSONFile,
176+
MicrosoftExcelFile,
177+
MicrosoftPowerPointFile,
178+
MicrosoftWordFile,
179+
SeparatedFile,
180+
XMLFile,
181+
)
182+
```
183+
142184
This package is under development, only supports create view. There are also no features related to image optimization. Use at your own risk.

0 commit comments

Comments
 (0)