Skip to content
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

Limit Size Upload #62

Closed
mpetyx opened this issue Jan 31, 2016 · 3 comments
Closed

Limit Size Upload #62

mpetyx opened this issue Jan 31, 2016 · 3 comments

Comments

@mpetyx
Copy link

mpetyx commented Jan 31, 2016

Hello,
I would like to ask if there is an option to limit the size upload somehow through the settings for example on my declaration below,
'imgs': ('uploads/imgs', lambda u: True, ['image/jpeg', 'image/png'],),

if it could be,
'imgs': ('uploads/imgs', lambda u: True, ['image/jpeg', 'image/png'],'10MB'),
or
'imgs': ('uploads/imgs', lambda u: True, ['image/jpeg', 'image/png'], lambda file: file._size> 10*1024*1024),

Is there a default field or parameter to monitor in order to throw an exception if someone goes above my preferred threshold?
I am looking for something similar to the discussions here and here.
Thank you very much in advance!

@ivanvenosdel
Copy link
Contributor

I would like to see this feature as well and have put some thought into it's implementation.

Since django-s3direct never touches the file directly (by design). It would need to rely on S3 to do the content-size checking. That is achieved by way of a "content-length-range" in the post policy.

Presently the policy is constructed using the positional values provided in the value of each key within the S3DIRECT_DESTINATIONS setting.

For these advanced cases, instead of adding a positional that is specific to this condition. The project could add one that is for a dictionary of arbitrary conditions to add to the post policy. I think that change would better shield the project maintainers from having to field future issues for new one-off-site-specific conditions yet still make it possible for those that would like to utilize a new condition.

I might be able to do a PR for this (or a new positional just like the others) later if the project maintainer expresses interest.

@bradleyg
Copy link
Owner

Definitely interested :)

@ivanvenosdel
Copy link
Contributor

Great! I should have something in ~1-2wks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants