Git Product home page Git Product logo

filepicker-django's People

Contributors

asilachev avatar bkwi avatar brettcvz avatar btbonval avatar johncosta avatar jonathan3 avatar nickpresta avatar nimate avatar nykakin avatar sethwoodworth avatar smartt avatar solyony avatar w- avatar wjoz 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

Watchers

 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

filepicker-django's Issues

Filepicker widget doesn't work within InlineAdmin

I have an FPUrlField within a Django admin inline model which works fine at first. However, when clicking on "add another" below the currently visible inlines, the newly appearing "Pick File" button does not pop up the Filepicker panel as expected. Instead, it submits the form and saves the model.

I'm guessing that Filepicker's JS API only adds the "Pick File" button's click event handler when it's visible on first page load. Since the additional forms that the Django admin adds are invisible at first, the event handler doesn't get attached and the button ends up working as a regular "submit" button.

I'm not sure how to solve this. Maybe adding a method to the JS API that makes it go through all widgets again and re-attach the event handler?

What is the proper s3 implementation?

Since the FPFileField requires an upload_to parameter, that can't be empty or "/", and the Filepicker service uploads to the root of my bucket (I don't see anywhere to configure this through the UI), how do I access the file?

With a model field like the one below, I get headshot.url as /uploads/file_name.ext, instead of the filename generated by filepicker.

headshot = FPFileField(blank=True, upload_to='uploads')

What is the default implementation for django_filepicker and s3?

doesn't retrieve file for update form

On class based update form,
when the field is required,
because filepicker doesn't retrieve the file you have to send it back ...

i think it's not good

S3 Url

I'm sure I've overlooked something here, but I'm using s3, and everything is uploading correctly. However, when I try to retrieve the file with something like...

<img src="{{ model.fpfile.url }}"> 

it's returning the s3 url, but without the unique id.

Update README.md to mention the needed settings changes

The README.md example was almost good enough to run with; However, it didn't mention the two needed changes to settings.py: The inclusion of a FILEPICKER_API_KEY variable, and the addition of the filepicker middleware. The error messages you'll see when trying to integrate the code will point these out -- but it would have saved a few minutes of digging through the demo-project's code if this information were provided up-front.

Cheers!

FilepickerFile manages files outside its context

I'm seeing a problem where FilepickerFile.get_file returns the Python file object wrapped in a Django File object. At that point, FilepickerFile is not needed, but the Django File might yet get passed around.

While the Django File is being used, the FilepickerFile object is dropped from context and gets garbage collected. It promptly closes the Python file and deletes the temporary file.

Unfortunately, that was the file descriptor that the Django File is still using, which leads to errors about trying to read from a closed file: ValueError: I/O operation on closed file.

FilepickerFile really has no reason to track the Python file other than to close it, but Django File should take care of that.

FilepickerFile does need a temporary file, but it doesn't need to delete the file itself. Ideally, one would use os.tmpfile or something from the tempfile module, which will take care of deleting the file from the FS after all file descriptors have been closed (e.g. Django File is all done with the python file).

If both changes were made, FilepickerFile wouldn't need any cleanup at all, nor would it interfere with the Django File it spawns from FilepickerFile.get_file().

Unfortunately urllib doesn't offer any way to download into a file-like object, it can only download into filenames. It doesn't seem clear how to download into a pre-opened temporary file using urllib or urllib2.

The third party requests library is a great replacement for urllib*. This would be the thing to use with a Python-maintained temporary file: http://docs.python-requests.org/en/latest/user/quickstart/#raw-response-content

Upgrading tries to upgrade Django

This is a small thing but somewhat annoying: everytime I do an pip install -U django-filepicker, it tries to upgrade Django as well. This seems to be because in setup.py it says

install_requires=['django']

Can we assume that anyone using django-filepicker has Django installed? That would make upgrading with pip go much more smoothly...

Signature and Policy are ignored when retrieving files

The Filepicker URL needs policy and signature attached as query parameters when such security policies are in effect.

I already rewrote to_python in FPFileField to make use of self.additional_params in my local copy, which I can submit as a pull request.

Ideally this code would go into utils.FilepickerFile.get_file as per #23, but that utility does not have access to the additional parameters found in FPFileField. They'll have to be parameters somewhere.

filepicker and S3

(slightly different than #29 )

We currently have our image model as models.FPFileField. The issue we ran into is when people upload via dropbox and then move/delete their image in dropbox, it disappears from our site. Someone at Ink told us to setup S3 and then use the pickAndStore method to place those files in S3 so they are no longer links to Dropbox.

The response to #29 is to use FPUrlField which is in forms not models. It is implied that FPFileField store the image locally and remotely while FPUrlField just stores remotely(S3). I don't think any of the images are actually being stored locally in our case as they are all filepicker links (which in the case of dropbox are merely references).

I'm sorry if I sound clueless as I am trying to wrap my head around filepicker and it's implementation at our site. I basically need to know, once I setup our FilePicker account to use S3, how to emulate the pickAndStore functionality so all new pictures picked by customers are stored at S3 and the links stay good regardless of what happens to the original image.

Thanks!

File retrieval code is duplicated

Retrieving a file from Filepicker is written in two different places. Appears to be copy/paste.

It seems like FPFileField.to_python should be rewritten something like this:

def to_python(self, data):
    try:
        fd = FilepickerFile(data)
    except ValueError, e:
        if 'Not a filepicker.io URL' in str(e):
            # return None if data isn't a valid Filepicker URL
            return None
        else:
            # otherwise pass the buck
            raise e
    else:
        return fd.get_file()

The elses in the above code are not strictly necessary.

UnboundLocalError: local variable ‘name’ referenced before assignment

I'm getting this error in my application every time I try to upload a file (0.2.2):

File "/django_filepicker/utils.py", line 62, in get_file
  file = File(tmp, name=name)
UnboundLocalError: local variable ‘name’ referenced before assignment

I suppose I am getting this because neither the X-File-Name nor Content-Disposition headers are being set by the application.
The thing is I'm not sure why, can you shed me a light?

Also, maybe that's something you wanna protect from, like having a default for the name variable maybe?

Thanks!

Python 3 not supported, lack of support undocumented in setup.py

Django now fully supports Python 3, but this plugin does not, and setup.py does not specify supported versions. As a result, this plugin will install but crash if Python 3 is used.

According to the 2to3 tool, Converting the plugin to support Python 3 will involve at least the following:

  • changing all relative imports from e.g. import models to from . import models
  • migrating from urllib and urllib2 to the new urllib modules and submodules
  • changing try/except deprecated syntax from e.g. except ValueError, e: to except ValueError as e:

... and some other small changes.

It should be possible to support python 2 and python 3 simultaneously.

Uncaught Error: SecurityError

Whenever I take the demo, and run it on my local server, I can pull up the upload dialoge, but it keeps throwing a javascript error when i select the file to upload:
Uncaught Error: SecurityError: DOM Exception 18

Which then freezes the page at a spinning uploading screen. My API key has been entered as well.

Cannot specify no mimetypes

I'm working with a codebase which specifies data-fp-extensions.

FilepickerException: Error: Cannot pass in both mimetype and extension parameters to the pick function

I have specified FPFileField.mimetypes to be nothing, None, '', (,), and always it comes back */*. So then I read the code and figured out why:
https://github.com/Ink/django-filepicker/blob/0671c4315b61f897358367a757b6ef8444aa183b/django_filepicker/forms.py#L33

Please specify at least one condition in which mimetypes may be left blank.

On the one hand, you could explicitly check to see if 'data-fp-extensions' in additional_params, in which case mimetypes should not be included.

On the other hand, there might be other instances where mimetypes cause a problem. It might be hard to find all those edge cases. Perhaps add a constant NoMimetypes = object() singleton into forms.py, and do not include mimetypes if mimetypes == NoMimetypes.

Enhancement? - Multiple-Files

Is there currently a suggested to handle multiple files with django? My app calls for this and I am thinking the easiest way may be to have a model for the InkBlob that points back to the related model.

I'm thinking of hooking into the success callback and then taking care of the FK with some ajax.

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.