Skip to content

Commit

Permalink
Merge pull request #34 from conikuvat/limitconcurrentuploads
Browse files Browse the repository at this point in the history
Limit concurrent uploads
  • Loading branch information
gkuhn1 authored Jan 13, 2019
2 parents 2195fc1 + 4cc4e48 commit a9d6406
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ Usage
multiupload_maxfilesize = 3 * 2 ** 20 # 3 Mb
# min allowed filesize for uploads in bytes
multiupload_minfilesize = 0
# limit concurrent uploads in order to avoid timeouts (try 6–10 if experiencing problems)
multiupload_limitconcurrentuploads = None
# tuple with mimetype accepted
multiupload_acceptedformats = ( "image/jpeg",
"image/pjpeg",
Expand Down Expand Up @@ -92,8 +94,3 @@ Usage

Checkout some full example project in example folder.
Superuser: Login: demo Pass: demo





Binary file modified example/db.sqlite3
Binary file not shown.
3 changes: 2 additions & 1 deletion example/gallery/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ def delete_file(self, pk, request):
class ImageAdmin(GalleryMultiuploadMixing, MultiUploadAdmin):
multiupload_form = False
multiupload_list = True
multiupload_limitconcurrentuploads = 6


admin.site.register(Gallery, GalleryAdmin)
admin.site.register(Image, ImageAdmin)
admin.site.register(Image, ImageAdmin)
5 changes: 5 additions & 0 deletions multiupload/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class Media:
multiupload_acceptedformats = ("image/jpeg",
"image/pjpeg",
"image/png", )
multiupload_limitconcurrentuploads = None

multiupload_view_context = {}

Expand Down Expand Up @@ -262,6 +263,10 @@ def admin_upload_view(self, request, id=None):
# some of the parameters to be checked by javascript
"maxfilesize": self.upload_options["maxfilesize"],
"minfilesize": self.upload_options["minfilesize"],
"limitconcurrentuploads": (
'undefined' if self.multiupload_limitconcurrentuploads is None
else self.multiupload_limitconcurrentuploads
),
# django admin parameters
"object": object,
'media': self.media,
Expand Down
3 changes: 2 additions & 1 deletion multiupload/templates/multiupload/upload.html
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@

// Initialize the jQuery File Upload widget:
$('#fileupload').fileupload({
formData: [{ name: "csrfmiddlewaretoken", value: "{{ csrf_token }}"}]
formData: [{ name: "csrfmiddlewaretoken", value: "{{ csrf_token }}"}],
limitConcurrentUploads: {{ limitconcurrentuploads }}
}).bind('fileuploadsubmit', function (e, data) {
var inputs = data.context.find(':input');
if (inputs.filter('[required][value=""]').first().focus().length) {
Expand Down

0 comments on commit a9d6406

Please sign in to comment.