python3 -m pip install -U drf_file_manager
Windows needs install extra: python-magic-bin
python3 -m pip install python-magic-bin
- Add
drf_file_manager
to yourINSTALLED_APPS
setting:
# settings.py
INSTALLED_APPS += [
'rest_framework',
'drf_file_manager',
]
- Configuration for
drf_file_manager
:
# settings.py
FILE_UPLOAD_TO = 'data/upload/'
FILE_UPLOAD_MAX_SIZE = '10M' # [optional]
- Add
drf_file_manager.urls
to your project's urls.py:
# urls.py
urlpatterns += [
include('api/file/', include('drf_file_manager.urls')),
]
-
POST /api/file/
- Upload a file -
GET /api/file/
- List all files -
GET /api/file/{id}/
- Retrieve a file -
GET /api/file/{id}/download/
- Download a file (with streaming support) -
DELETE /api/file/{id}/
- Delete a file -
POST /api/file/clean/
- Delete all files