The question is stated above. While there are many tutorials about file upload using django rest framework. None mentioned about the resumable version of it. And I need to implement it for a project. Can someone point me to some resources or give a sample code? Help is greatly appreciated.
UPDATE
This is what I have gotten so far.
views.py
class FileUploadView(views.APIView):
parser_classes = (FormParser, MultiPartParser)
def put(self, request, format=None):
file_obj = request.data['file']
self.handle_uploaded_file(file_obj)
return Response(status=204)
def handle_uploaded_file(self, ufile):
filename = "{0}/{1}".format(settings.MEDIA_ROOT, ufile)
with open(filename, "wb+") as target:
for chunk in ufile.chunks():
target.write(chunk)
curl command
curl -H "Content-Disposition: attachment; filename=try.py" -X PUT -F "file=@try.py" http://localhost:8000/api/fileupload/?filename=testing
try.py
from django.test import TestCase
# Create your tests here.
The next part is how to make it resumable.