Exemplo n.º 1
0
    def get(self, request, person_guid):
        person = get_object_or_404(self.queryset, pk=person_guid)
        client = MinioClient(
            request=request, disable_private=False)

        object_name = request.GET.get("filename")
        filename = client.format_object_name(object_name, person.person_guid, "driller")
        bucket_name = get_env_variable("S3_REGISTRANT_BUCKET")

        # All documents are private for drillers
        url = client.get_presigned_put_url(
            filename, bucket_name=bucket_name, private=True)

        return JsonResponse({"object_name": object_name, "url": url})
Exemplo n.º 2
0
    def get(self, request, aquifer_id, **kwargs):
        client = MinioClient(request=request, disable_private=False)

        object_name = request.GET.get("filename")
        filename = client.format_object_name(object_name, int(aquifer_id),
                                             "aquifer")
        bucket_name = get_env_variable("S3_AQUIFER_BUCKET")

        is_private = False
        if request.GET.get("private") == "true":
            is_private = True
            bucket_name = get_env_variable("S3_PRIVATE_AQUIFER_BUCKET")

        url = client.get_presigned_put_url(filename,
                                           bucket_name=bucket_name,
                                           private=is_private)

        return JsonResponse({"object_name": object_name, "url": url})
Exemplo n.º 3
0
    def get(self, request, submission_id):
        submission = get_object_or_404(self.queryset, pk=submission_id)

        client = MinioClient(
            request=request, disable_private=False)

        object_name = request.GET.get("filename")
        filename = client.format_object_name(object_name, int(submission.well.well_tag_number), "well")
        bucket_name = get_env_variable("S3_ROOT_BUCKET")

        is_private = False
        if request.GET.get("private") == "true":
            is_private = True
            bucket_name = get_env_variable("S3_PRIVATE_ROOT_BUCKET")

        url = client.get_presigned_put_url(
            filename, bucket_name=bucket_name, private=is_private)

        return JsonResponse({"object_name": object_name, "url": url})
Exemplo n.º 4
0
    def get(self, request, tag, **kwargs):
        well = get_object_or_404(self.queryset, pk=tag)
        client = MinioClient(request=request, disable_private=False)

        object_name = request.GET.get("filename")
        filename = client.format_object_name(object_name,
                                             int(well.well_tag_number), "well")
        bucket_name = get_env_variable("S3_ROOT_BUCKET")

        is_private = False
        if request.GET.get("private") == "true":
            is_private = True
            bucket_name = get_env_variable("S3_PRIVATE_ROOT_BUCKET")

        # TODO: This should probably be "S3_WELL_BUCKET" but that will require a file migration
        url = client.get_presigned_put_url(filename,
                                           bucket_name=bucket_name,
                                           private=is_private)

        return JsonResponse({"object_name": object_name, "url": url})