Beispiel #1
0
def remove_object(resource, bucket_name, object_name):
    try:
        bucket_lib.remove_object(resource, bucket_name, object_name)
        click.secho(f'Object "{object_name}" removed successfully', fg="green")
    except Exception as exc:
        click.secho(f"Object removal failed. \n{exc}",
                    fg="yellow",
                    bold=True,
                    err=True)
Beispiel #2
0
    def delete(self, bucket_name):
        parser = init_parser().copy()
        parser.add_argument("object_name", type=str, required=True)
        args = parser.parse_args()
        secret_key = args["secret_key"].replace(" ", "+")

        try:
            result = bucket.remove_object(
                get_resources(args["access_key"], secret_key),
                bucket_name,
                args["object_name"],
            )
            return response(
                200, f"Object {args['object_name']} deleted successfully.",
                result)
        except Exception as e:
            current_app.logger.error(f"{e}", exc_info=args["debug"])
            return response(500, f"{e}")