def post_list(self, request, **kwargs): s3_object_type = request.POST.get('s3_object_type', 'application/octet-stream') s3_object_name = request.POST.get('s3_object_name', None) if None in (s3_object_type, s3_object_name): raise HttpBadRequest() url = generate_signed_url(s3_object_name, s3_object_type, method='PUT') result = { 'url' : url } return self.create_response(request, result)
def generate_s3_url(request): """ Generates a one time use URL for uploading files to S3 """ s3_object_type = request.POST.get('s3_object_type', 'application/octet-stream') s3_object_name = request.POST.get('s3_object_name', None) if not s3_object_name: raise ParseError('You need to provide object name and type') url = generate_signed_url(s3_object_name, s3_object_type, method='PUT') result = { 'upload_url' : url } return Response(result)