Skip to content

Commit afedc32

Browse files
committed
Switch readme from Markdown to reStructuredText
1 parent c5a29dd commit afedc32

File tree

3 files changed

+111
-138
lines changed

3 files changed

+111
-138
lines changed

README.md

-137
This file was deleted.

README.rst

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
django-s3file
2+
=============
3+
4+
A lightweight file upload input for Django and Amazon S3.
5+
6+
Django-S3File allows you to upload files directly AWS S3 effectively
7+
bypassing your application server. This allows you to avoid long running
8+
requests from large file uploads.
9+
10+
|PyPi Version| |Build Status| |Test Coverage| |GitHub license|
11+
12+
Features
13+
--------
14+
15+
- lightweight: less 200 lines
16+
- no JavaScript or Python dependencies (no jQuery)
17+
- easy integration
18+
- works just like the build-in
19+
20+
Installation
21+
------------
22+
23+
*Make sure you have `Amazon S3 storage`_ setup correctly.*
24+
25+
Just install S3file using ``pip``.
26+
27+
.. code:: bash
28+
29+
pip install django-s3file
30+
31+
Add the S3File app and middleware in your settings:
32+
33+
.. code:: python
34+
35+
36+
INSTALLED_APPS = (
37+
'...',
38+
's3file',
39+
'...',
40+
)
41+
42+
MIDDLEWARE = (
43+
'...',
44+
's3file.middleware.S3FileMiddleware',
45+
'...',
46+
)
47+
48+
Usage
49+
-----
50+
51+
S3File automatically replaces Django’s ``ClearableFileInput`` widget,
52+
you do not need to alter your code at all.
53+
54+
The ``ClearableFileInput`` widget is only than automatically replaced
55+
when the ``DEFAULT_FILE_STORAGE`` setting is set to
56+
``django-storages``\ ’ ``S3Boto3Storage``.
57+
58+
Setting up the AWS S3 bucket
59+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
60+
61+
Upload folder
62+
~~~~~~~~~~~~~
63+
64+
S3File uploads to a single folder. Files are later moved by Django when
65+
they are saved to the ``upload_to`` location.
66+
67+
It is recommended to `setup expiration`_ for that folder, to ensure that
68+
old and unused file uploads don’t add up and produce costs.
69+
70+
The default folder name is: ``tmp/s3file`` You can change it by changing
71+
the ``S3FILE_UPLOAD_PATH`` setting.
72+
73+
CORS policy
74+
~~~~~~~~~~~
75+
76+
You will need to allow ``POST`` from all origins. Just add the following
77+
to your CORS policy.
78+
79+
.. code:: xml
80+
81+
<CORSConfiguration>
82+
<CORSRule>
83+
<AllowedOrigin>*</AllowedOrigin>
84+
<AllowedMethod>POST</AllowedMethod>
85+
<AllowedMethod>GET</AllowedMethod>
86+
<MaxAgeSeconds>3000</MaxAgeSeconds>
87+
<AllowedHeader>*</AllowedHeader>
88+
</CORSRule>
89+
</CORSConfiguration>
90+
91+
Uploading multiple files
92+
~~~~~~~~~~~~~~~~~~~~~~~~
93+
94+
Django does have limited `support to uploaded multiple files`_. S3File
95+
fully supports this feature. The custom middleware makes ensure that
96+
files are accessible via ``request.FILES``, even thogh they have been
97+
uploaded to AWS S3 directly and not to your Django application server.
98+
99+
.. _Amazon S3 storage: http://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html
100+
.. _setup expiration: http://docs.aws.amazon.com/AmazonS3/latest/dev/intro-lifecycle-rules.html
101+
.. _support to uploaded multiple files: https://docs.djangop
102+
103+
.. |PyPi Version| image:: https://img.shields.io/pypi/v/django-s3file.svg
104+
:target: https://pypi.python.org/pypi/django-s3file/
105+
.. |Build Status| image:: https://travis-ci.org/codingjoe/django-s3file.svg?branch=master
106+
:target: https://travis-ci.org/codingjoe/django-s3file
107+
.. |Test Coverage| image:: https://codecov.io/gh/codingjoe/django-s3file/branch/master/graph/badge.svg
108+
:target: https://codecov.io/gh/codingjoe/django-s3file
109+
.. |GitHub license| image:: https://img.shields.io/badge/license-MIT-blue.svg
110+
:target: https://raw.githubusercontent.com/codingjoe/django-s3file/master/LICENSE

setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = django-s3file
33
author = Johannes Hoppe
44
author-email = [email protected]
55
summary = A lightweight file uploader input for Django and Amazon S3
6-
description-file = README.md
6+
description-file = README.rst
77
home-page = https://github.com/codingjoe/django-s3file
88
license = MIT
99
classifier =

0 commit comments

Comments
 (0)