Exemplo n.º 1
0
 def upload(self, request, pk):
     files = request.data['files']
     incident = get_object_or_404(Incident, pk=pk)
     files_added = []
     for i, file in enumerate(files):
         file_obj = FileWrapper(StringIO.StringIO(file['content']))
         file_obj.name = file['filename']
         description = file['description']
         f = handle_uploaded_file(file_obj, description, incident)
         files_added.append(f)
     resp_data = FileSerializer(files_added, many=True, context={'request': request}).data
     return HttpResponse(JSONRenderer().render(resp_data), content_type='application/json')
Exemplo n.º 2
0
 def upload(self, request, pk):
     files = request.data['files']
     incident = get_object_or_404(Incident, pk=pk)
     files_added = []
     for i, file in enumerate(files):
         file_obj = FileWrapper(StringIO.StringIO(file['content']))
         file_obj.name = file['filename']
         description = file['description']
         f = handle_uploaded_file(file_obj, description, incident)
         files_added.append(f)
     resp_data = FileSerializer(files_added, many=True, context={'request': request}).data
     return HttpResponse(JSONRenderer().render(resp_data), content_type='application/json')