this a apiview to upload files , i don't know where is the mistake class Article_upload(APIView): parser_classes = (FileUploadParser,) def post(self, request, *args, **kwargs): file_obj = request.FILES.get('file')
if file_obj is None: return Response({'error': 'No file found in the request'}, status=status. HTTP_400_BAD_REQUEST) if not file_obj.name.endswith('.pdf'): return Response({'error': 'File must be a PDF'}, status=status. HTTP_400_BAD_REQUEST) # Process the uploaded PDF file as needed (e.g., save to disk, extract information, etc.) # In this example, we are just returning the file name in the response. return Response({'filename': file_obj.name}, status=status.HTTP_201_CREATED) -- You received this message because you are subscribed to the Google Groups "Django REST framework" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-rest-framework/30287793-ae94-49ce-a5ee-77b6a55b04a0n%40googlegroups.com.