-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong design of Base64 file fields #111
Comments
At the very least one should be able to provide '*' as a parameter to bypass the check. That would be easy enough to implement. |
I'm reading https://github.com/Hipo/drf-extra-fields/blob/master/drf_extra_fields/fields.py#L52 and unless I am reading it wrong this code will never do anything at all. It makes a uuid4 to use as a filename and then checks if the extension (!!) of the uuid4 string is in ALLOWED_TYPES. This results in a contradiction. |
Hey @arnists thanks for your contributions.
Yes, you are right. We have an open PR #72 but it's not completed, documentation and tests are missing. Would you like to help on that?
|
Hi @arnists Do you have any suggestion to improve design of the Base64 fields? I am happy to hear your suggestions? |
I do. I didn't get a lot of sleep tonight so I couldn't make a relevant contribution today. I ended up reworking the field in my project and using it changed a bit. I'll see if I can make a PR tomorrow with my code. I'll also see if I can make a more sweeping architectural change. |
youd want something like this @arnists fields.py
serializers.py
|
I understand how you arrive at this design because it serves the usecase of checking if an image is an image file and that image files have few extensions. It makes the generic component very hard to use if you simply need something that serializes/deserializes base64 for storage or retrieval. It's reminiscent of Interfaces in Java.
At most you should take these functions as parameters so that one can provide a lambda on field construction.
Most of the time I wouldn't have spent the time making an issue, just ripped the code I needed and gone about my day. This seems to be a good library thou and I'm willing to put in effort to make it better.
I don't know how to best go about it. A discussion on a goal seemed to be the right place to start.
The text was updated successfully, but these errors were encountered: