Git Product home page Git Product logo

django-ajax-uploader's Introduction

This is codebase for stevenskoczen.com, including the Steven Manual. This is the project where I've taken those code skills I use to great effect professionally and artistically, and turned them on myself, and my life. Nothing here is generalized, or for some broader purpose. This is my project to be selfish, to help me wring every bit out of the seconds of my life.

You might find it useful, but I'd bet probably not. See, unlike most of my other projects, the Steven Manual has only one code rule: this code is never going to be reused, repurposed, or serve some greater general good. Hacks are totally fine here. Duct-tape is great. Hideous memory usage, design, and abuse of programming paradigms are all done and applauded. There is only one user, and they're quite understanding - because they're me.

django-ajax-uploader's People

Contributors

bee-keeper avatar chrisjones-brack3t avatar chromano avatar dannybrowne86 avatar eryckson avatar fcurella avatar fhahn avatar gilsondev avatar minddust avatar oldhacksy avatar onlyinamerica avatar onyxfish avatar owenmead avatar paepke avatar shockflash avatar sjl avatar skoczen avatar truetug avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-ajax-uploader's Issues

how to limit file count?

How to limit file upload by file count on browser side? Any options or i must edit script code?

create_on_upload signal not work

Hi,
i am use your django-ajax-uploader it work properly it uploded image but now i want to save his patyh in models in django for that i am use signal mention in doc

in models.py

class Product_image(TranslatableModel):

translations = TranslatedFields(
    product = models.ForeignKey('Product', verbose_name=_('Product'), null=True, blank=True),
    document = models.FileField(upload_to='attachments/%Y/%m/%d',blank=True, null=True),
)


@receiver(file_uploaded, sender=AjaxFileUploader)
def create_on_upload(sender, backend, request, **kwargs):
    Product_image.objects.create(document=backend.path)

def __str__(self):
    return str(self.product)

image uplod in upload folder properly but path not save in models
how can i get this
Thanks in advance!!!

Improvement of README

I'm installing this app and was necessary change the code of views for successful test:

 from django.shortcuts import render_to_response
 from ajaxuploader.views import AjaxFileUploader
 from django.middleware.csrf import get_token

 def start(request):
     csrf_token = get_token(request)
     return render_to_response(request, 'import.html', {'csrf_token': csrf_token})

 import_uploader = AjaxFileUploader()

Should be:

from django.middleware.csrf import get_token
from django.shortcuts import render_to_response
from django.template import RequestContext

from ajaxuploader.views import AjaxFileUploader

def start(request):
    csrf_token = get_token(request)
    return render_to_response('import.html',
        {'csrf_token': csrf_token}, context_instance = RequestContext(request))

import_uploader = AjaxFileUploader()

with s3 ajax uploder control not render in template

hi ,
i want to use your ajax uploader with s3 bucket on aws
first i installed ajaxuploder , boto
after i do
python manage.py collectstatic
all static file transfer to s3 bucket

after i define static variable in settings.py
AWS_UPLOAD_BUCKET_NAME = "bucket-to-upload-to"
AWS_UPLOAD_CLIENT_KEY = "public-aws-upload-key"
AWS_UPLOAD_CLIENT_SECRET_KEY = "secret-aws-upload-key"

then after i add url in my main url.py

url(r'^ajax-uploader/', include('ajaxuploader.urls', namespace='ajaxuploader', app_name='ajaxuploader')),

and then i add following code in template and "fine_uploader" div as well

<script>
var uploader = new qq.s3.FineUploader({
    element: document.getElementById('fine_uploader'),
    request: {
    endpoint: '{{ AWS_UPLOAD_BUCKET_NAME }}.s3.amazonaws.com',
    accessKey: {{ AWS_CLIENT_ACCESS_KEY }}
    },
    signature: {
    endpoint: '{% url "ajaxuploader:s3_signature" %}'
    },
    uploadSuccess: {
    endpoint: '{% url "ajaxuploader:s3_success" %}' 
    },
    iframeSupport: {
    localBlankPagePath: '/success.html'
    },
    deleteFile: {
    enabled: true,
    endpoint: '{% url "ajaxuploader:s3_delete" %}'
    },
});
</script>

but upload control not render in template
how can i get that

Add support in js library to mention notAllowedExtensions

As we have allowedExtensions property in js library, we should also have notAllowedExtensions which will make things little bit easier. For example i want the user to be able to upload all files instead of those files which has extension .exe

If user has defined allowedExtensions always take priority over notAllowedExtensions. For example if mistakenly i have defined a .exe extension in both then allowedExtension should always consider first.

S3 Upload

Uploaded files are empty (0 bytes)

Failed uploads

I'm not sure what's going wrong here. I followed the installation instructions but when ever I try to upload a file over about 1MB I get an upload failed message.

Additionally, I can upload files under 1MB with the local backend but when I try and upload to the S3 backend it just creates an empty 0 byte file in the bucket.

s3 Upload Error - Cannot Allocate Memory

I've been getting this error occasionally, and it seems regardless of the filesize. Heres the traceback:

File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py", line 111, in get_response
response = callback(request, _callback_args, *_callback_kwargs)

File "/srv/venvs/launch/src/ajaxuploader/ajaxuploader/views.py", line 14, in call
return self._ajax_upload(request)

File "/srv/venvs/launch/src/ajaxuploader/ajaxuploader/views.py", line 51, in _ajax_upload
backend.setup(filename)

File "/srv/venvs/launch/src/ajaxuploader/ajaxuploader/backends/s3.py", line 26, in setup
self._pool = Pool(processes=self.NUM_PARALLEL_PROCESSES)

File "/usr/lib64/python2.6/multiprocessing/init.py", line 227, in Pool
return Pool(processes, initializer, initargs)

File "/usr/lib64/python2.6/multiprocessing/pool.py", line 104, in init
w.start()

File "/usr/lib64/python2.6/multiprocessing/process.py", line 104, in start
self._popen = Popen(self)

File "/usr/lib64/python2.6/multiprocessing/forking.py", line 94, in init
self.pid = os.fork()

OSError: [Errno 12] Cannot allocate memory

I'm running on a micro EC2 instance uploading using the s3 backend.

Practical to switch to Django-Storages?

I'm thinking it may be beneficial to switch to using django-storages instead of the custom backends implemented here. Maybe this is pointless, i'm still not that savvy with django/python so perhaps that doesn't make sense.

InputName is hardcoded as 'qqfile'

During an ajax upload filename is getting from GET by the hardcoded key qqfile:

try:
    filename = request.GET['qqfile']
except KeyError:
    return HttpResponseBadRequest("AJAX request not valid")

Whereas it might be changed in a fileuploader instance (inputName option).

filtering by mimetype

Hi GoodCloud,

Is there any way to prevent uploading (on client side or on server side, in the backend) from specific file extension.
For example I just want to upload png's and epub's
Is there a consistant way to do this? with a little bit of code ?

Thanks for your answer

Thumbnail as a config?

My use case is to upload a thumbnail / cropped photo to the same backend I am storing it in. It looks like the thumbnail backend only stores things locally, but maybe i've read the code wrong.

Not sure how to run tests

Maybe its because i'm a bit new to django, but i'm not sure how to run the tests with this project. When i try python run_tests.py i get this warning:

(sandbox)โžœ  django-ajax-uploader git:(master) python run_tests.py
Traceback (most recent call last):
  File "run_tests.py", line 36, in <module>
    main()
  File "run_tests.py", line 32, in main
    call_command('test', 'ajaxuploader')
  File "/home/derek/Dev/.tools/virtualenv/python/sandbox/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 93, in call_command
    app_name = get_commands()[name]
  File "/home/derek/Dev/.tools/virtualenv/python/sandbox/local/lib/python2.7/site-packages/django/utils/lru_cache.py", line 101, in wrapper
    result = user_function(*args, **kwds)
  File "/home/derek/Dev/.tools/virtualenv/python/sandbox/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 73, in get_commands
    for app_config in reversed(list(apps.get_app_configs())):
  File "/home/derek/Dev/.tools/virtualenv/python/sandbox/local/lib/python2.7/site-packages/django/apps/registry.py", line 137, in get_app_configs
    self.check_apps_ready()
  File "/home/derek/Dev/.tools/virtualenv/python/sandbox/local/lib/python2.7/site-packages/django/apps/registry.py", line 124, in check_apps_ready
    raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.

Ideas for adding different upload client options

There are a couple promising projects w/o commercial licensing issues, such as fine uploader. These would make great replacements for the outdated fileuploader.js / fine uploader. I'm thinking a simple sub module in the js folder may suffice.

Vanilla:
pluploader - im pretty sold on this actually.

jQuery:
Blue Imps File Uploader
DropZone

... probably 10 different alternatives i haven't bothered tracking down/listing.

Memory usage with bigger files

Uploading huge files seems to be problematic. I've tried to upload a 3GB file and the apache wsgi process slowly took up the entire 12GB RAM of the server. Using the cancel link didn't stop it and i had to restart apache in order to prevent further swapping.

Now i understand that http was never designed to handle huge uploads, but i'm wondering why the process eats up that much of memory. While the file is being uploaded, the RAM usage slowly increases by the amount of the filesize, which is fine i think. After it reaches 100% upload process however, the memory usage goes up further and the file is not written.

Using the django dev server, this behaviour is even more visible. Here a file of about 200MB is enough to make my machine with 4GB RAM swap.

I override upload_complete in my custom Backend which moves the uploaded file to another location using shutil.move. I first thought this was the problem, but it's the same when i use the included LocalUploadBackend.

Additional model fields

Hi

Great library. Worked first time. Just wondering if there is a way to add additional model fields to the upload form which can then be accessed via the signal. e.g. I have a file description and checkbox that need sending along with the file.

Thanks

Detecting upload cancellation in backend

My issue is when the uploading is canceled midway, an empty file (image in my case) gets uploaded, I need to deal with that issue on the back-end side of my code so I need to ask how to detect the upload cancellation in the back-end and where is that triggered from in the front end, do I need to write a function onCancel or is it taken care of automatically.

Thanks in advance

the import.html in example

I am confused with the following code:

def start(request):
    csrf_token = get_token(request)
    return render_to_response('import.html',
        {'csrf_token': csrf_token}, context_instance = RequestContext(request))

I know the meaning of the code,
but dont know when will django-ajax-uploader use request the method start,
and no template named import.html in the repository

Loading an empty file

Hello.

If i use your 'fileuploader.js', files are loading correctly, but if i use latest version of fileuploader files are loaded empty (0 bytes).

I opened the debugger and saw that the new version of fileuploader sends request like this

  Content-Type:multipart/form-data;

How i can fix it?

python 2.5 issue

The module io is not available for python 2.5 and less. so it creates an exception when importing the file local.py.

Empty file

When I try to upload it creates file on server with 0 bytes, in firebug result is all ok, What I did to resolve problem is I use mbraak fork and is working.

Working on IE10 ?

Hi, I try this script. It works on Chrome and Firefox but does not seem to work with IE ? Someone else has noticed it ?

Progress Upload Bar Not Working

Hi,

I would like to know if the Ajax Uploader supports a progress bar for Amazon S3?
Currently it goes from 0 to 100% before the upload finishes.

Thanks!

Bug with commit #80a5a9d7bd24528e069ed123369ce8c7e5569ff0

I've already install this app, but when i load the template i get this error:

Uncaught TypeError: Cannot set property 'innerHTML' of null
qq.FileUploaderfileuploader.js:529
(anonymous function):8000/ajax_upload/:7

I just follow the instructions, the template is the same in example and code, the view is this;

def upload_profile_photo(request):
    csrf_token = get_token(request)
    data = {'csrf_token': csrf_token}   
return render_to_response('venue_profile_photos/index.html', data, context_instance=RequestContext(request))

upload_profile_photo_send = AjaxFileUploader()

My webbrowser is google chrome 16.0.891.0 dev but neither works with firefox 6.0.2

Any thoughts?

AJAX request not valid

Hi ,

I have installed fineuploader.js and try to upload files but i get error AJAX request not valid?

I think the error is because of GET['qqfile'] ...
try:
filename = request.GET['qqfile']
except KeyError:
return HttpResponseBadRequest("AJAX request not valid")

How can i get rid of this error? Thanks

Unit test failure

The following issue is driven me crazy:

What I've done:
I customized the LocalUploadBackend and the AjaxFileUploader classes a bit, because of thumbnail stuff and so on.
Now I tried to write some tests, but after hours of debugging it still doesn't work.

What 've found out:
When I'm into debug and stop at the following code sample....:

success = backend.upload(upload, filename, is_raw)

...then calling request.POST in my debug I/O to check for the hexa stuff of the file (everything seems ok). In this case the whole test works and the file is uploaded.

When I'm not into debug mode and run the test without calling request.POST the following error appears:

AssertionError: Cannot read more than the available bytes from the HTTP incoming data.

Would be awesome if you can help me with that. Thanks!

FineUploader with Django 1.11.15

Hi

I have a legacy site that needs to switch to using FineUploader but its built using Django 1.11.15

I've followed all the setup instructions and alls well until I try to upload and it gives the following error:

Traceback:  

File "/home/mike/Documents/python/dbi_website/local/lib/python2.7/site-packages/django/core/handlers/base.py" in _get_response
  185.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/home/mike/Documents/python/dbi_website/local/lib/python2.7/site-packages/ajaxuploader/views/base.py" in __call__
  22.         return self._ajax_upload(request, *args, **kwargs)

File "/home/mike/Documents/python/dbi_website/local/lib/python2.7/site-packages/ajaxuploader/views/base.py" in _ajax_upload
  36.                         filename = request.REQUEST['qqfilename']

Exception Type: AttributeError at /projects/ajax-upload/1/
Exception Value: 'WSGIRequest' object has no attribute 'REQUEST'

I'm pretty sure its the older version of Django that doesn't have the 'REQUEST' as part of its implementation of WSGIRequest so I was wondering what version of ajaxuploader might be compatible with FineUploader and my version of Django?

Remove print statements for boto warning

views/s3.py should remove print statements warning that boto is not installed. This should use a proper logger so that this can be silenced.

Or remove altogether. I'm using the local backend and getting these warnings for some reason.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.