-
-
Notifications
You must be signed in to change notification settings - Fork 14
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
Version 2.0 #60
Version 2.0 #60
Conversation
2e85d5f
to
f2c9d9c
Compare
eabe36c
to
9147424
Compare
@amureki would you care to review this? I completely rewrote this library. |
* Remove signing view Widgets are now signed when rendered. This behavior saves one call to the application server. * Add support for `accept` attribute Limit upload policy MIME-Type in `accept` attribute. * Add support for `multiple` file uploads * Remove `django-appconf` dependency * Remove progress bar * Add middleware to allow seamless Django integration * Add automatical `FileField.widget` overwrite * Add tests * Reduce file size * Reduce asset size
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I managed to get this working in a new test app, but an example app in the repo would be of a great help :)
What I got working is file upload to tmp/
but who's supposed to move the file over to the destination specified in upload_to
?
Some other general comments:
- there's
.gitmodule
file with references to some jquery plugins - would be nice to have a changelog available to see what needs to be upgraded from 1.2.1
README.md
Outdated
* no JavaScript or Python dependencies (no jQuery) | ||
* Python 3 and 2 support | ||
* Auto swapping based on your environment | ||
* works just like the buildin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo, s/buildin/built-in/
Also it's not entirely clear what's meant by built-in...
README.md
Outdated
* lightweight: less 200 lines | ||
* no JavaScript or Python dependencies (no jQuery) | ||
* Python 3 and 2 support | ||
* Auto swapping based on your environment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not clear to me what you mean here
README.md
Outdated
### Advanced usage examples | ||
Django does have limited [support to uploaded multiple files][uploading-multiple-files]. | ||
S3File fully supports this feature. The custom middleware makes ensure that files | ||
are accessible via `request.FILES`, even tho they have been uploaded to AWS S3 directly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/tho/though/
README.md
Outdated
Django does have limited [support to uploaded multiple files][uploading-multiple-files]. | ||
S3File fully supports this feature. The custom middleware makes ensure that files | ||
are accessible via `request.FILES`, even tho they have been uploaded to AWS S3 directly | ||
and not to you Django application server. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/you/your/
README.md
Outdated
MyS3FileView.as_view(), name='s3file-sign'), | ||
) | ||
``` | ||
S3File uses a strict policy and signature to grand clients permission to upload |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/grand/grant/
tests/testapp/forms.py
Outdated
class Meta: | ||
model = FileModel | ||
fields = ('file',) | ||
widgets = {'file': AutoFileInput} | ||
|
||
|
||
class ClearableUploadForm(forms.ModelForm): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This form doesn't seem to be used anywhere and can be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tests/test_forms.py:85
;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, somehow missed that. But actually do you really need these 2 identical forms here?
s3file/static/s3file/js/s3file.js
Outdated
return unescape(tag.childNodes[0].nodeValue) | ||
(() => { | ||
function parseURL (text) { | ||
console.log(text) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to keep this in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, thx ;)
README.md
Outdated
urlpatterns = patterns( | ||
... | ||
url(r'^s3file/', include('s3file.urls')), | ||
MIDDLEWARE_CLASSES = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When creating a new Django app the setting is now called MIDDLEWARE
and middleware are processed a bit differently. Docs should probably reflect that. In case you want to support both middleware versions (as IMO this library should) then there's https://docs.djangoproject.com/en/1.11/topics/http/middleware/#upgrading-pre-django-1-10-style-middleware
s3file/forms.py
Outdated
self.access_key = settings.AWS_ACCESS_KEY_ID | ||
self.secret_access_key = settings.AWS_SECRET_ACCESS_KEY | ||
self.bucket_name = settings.AWS_STORAGE_BUCKET_NAME | ||
self.upload_path = getattr(settings, 'S3FILE_UPLOAD_PATH', os.path.join('tmp', 's3fine')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably you meant tmp/s3file
not tmp/s3fine
as the default
s3file/forms.py
Outdated
'data-policy': force_text(self.get_policy()), | ||
'data-signature': self.get_signature(), | ||
'data-key': self.upload_folder, | ||
'data-s3-url': 'https://s3.amazonaws.com/%s' % self.bucket_name, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://s3.amazonaws.com/
works for us-east-1
and maybe some other regions but didn't work for me for eu-west-1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dang. can you show me tomorrow?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's the list of regions and s3 endpoints: http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region
I think you would need an extra setting where to specify S3 region for the bucket if you want to support regions other than us-east-1
@grunskis I think that should resolve most issues. |
Ok, will take a look again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool stuff! Now works much better :)
@@ -24,6 +24,6 @@ | |||
packages=['s3file'], | |||
include_package_data=True, | |||
install_requires=[ | |||
'django-appconf>=0.6', | |||
'django-storages', | |||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should also include boto
or boto3
here or document that one of these is required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well none of this works, if the BotoStorage isn't setup and configured. This usually is the first step. But I will make sure to mention this, in the setup guide. Thanks! having documentation reviewed is always really helpful.
Widgets are now signed when rendered. This behavior saves one
call to the application server.
accept
attributeLimit upload policy MIME-Type in
accept
attribute.multiple
file uploadsdjango-appconf
dependencyFileField.widget
overwrite