Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import json
- from rest_framework.decorators import api_view
- from rest_framework.response import Response
- @api_view(['POST'])
- def foo(request):
- attributes = json.loads(request.data['attributes']) # will be a 'dict'
- xsd_file = request.data['xsd_file'] # "InMemoryUploadFile" instance
- Iccs_file = request.data['Iccs_file'] # "InMemoryUploadFile" instance
- return Response("some response")
- class multipleFileUpload(APIView):
- def post(self, request):
- """
- :param request:
- :return:
- """
- try:
- #this will read attributes other than file
- str_value = request.POST["attributes"]
- print(str_value)
- #check if any file send in request if yes read all files one by one
- if len(request.FILES) != 0:
- for key in request.FILES:
- file_obj = request.FILES[key]
- print(file_obj.read()) #getting contents of the file in bytes
- return JsonResponse({"res": "got files"})
- except Exception as e:
- print(str(e))
- return JsonResponse({"res": "error"})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement