Fixed key/location

This commit is contained in:
Tris 2020-09-10 12:03:56 +10:00
parent 9575619d3b
commit 807997f239

View File

@ -73,8 +73,13 @@ class S3CompleteMixin(View):
self.object = self.get_object()
if self.always_set or not self.object.key:
uri = urlparse(request.GET['location'])
self.object.key = uri.path[1:]
if 'location' in request.GET:
uri = urlparse(request.GET['location'])
self.object.key = uri.path[1:]
elif 'key' in request.GET:
self.object.key = request.GET['key']
else:
raise KeyError("No key or location found")
self.object.save()
return super().get(request, *args, **kwargs)