ich versuche es hinzubekomme einen Dateiupload zu realisieren, wobei ich noch zusätzliche Informationen (z.B. Speicherpfad) mitschicken möchte.
Im Dokumentationsbeispiel wird in etwa dieses URL Schema angeben:
Code: Alles auswählen
re_path(r'^upload/(?P<filename>[^/]+)$', views.FileUpload.as_view())
Meine View schaut daher wieder so aus, wie sie in der rest_framework Doku beschrieben ist:
Code: Alles auswählen
class FileUpload(APIView):
parser_classes = [FileUploadParser]
def put(self, request, filename, format=None):
file_obj = request.data['file']
with open(filename, 'wb+') as outfile:
for chunk in file_obj.chunks():
outfile.write(chunk)
return Response(status=204)
Code: Alles auswählen
this.$axios.put('/upload/test.mp4', this.inputFile, config)
.then(res => console.log(res))
.catch(err => console.log(err))
Code: Alles auswählen
this.$axios.put('/upload/test.mp4', { data: { file: this.inputFile, path: '/test/path/' } }, config)
Code: Alles auswählen
this.$axios.put('/upload/?path="/test/path/"&file=test.mp4', this.inputFile, config)
Habt ihr eine Idee wie ich das umsetzten kann?