Esempio n. 1
0
def copy_object(resource, src_bucket, src_object_name, dest_bucket, dest_object_name):
    if src_object_name.endswith("/") or not src_object_name:
        click.secho(f"Object copy failed. \nExpecting filename", fg="yellow", bold=True)
        return

    try:
        bucket_lib.copy_object(
            resource, src_bucket, src_object_name, dest_bucket, dest_object_name
        )
        click.secho(f'Object "{src_object_name}" copied successfully', fg="green")
    except Exception as exc:
        click.secho(f"Object copy failed. \n{exc}", fg="yellow", bold=True, err=True)
Esempio n. 2
0
    def post(self, bucket_name):
        parser = init_parser().copy()
        parser.add_argument("object_name", type=str, required=True)
        parser.add_argument("copy_to", type=str, required=True)
        args = parser.parse_args()
        secret_key = args["secret_key"].replace(" ", "+")

        try:
            bucket.copy_object(
                get_resources(args["access_key"], secret_key),
                bucket_name,
                args["object_name"],
                args["copy_to"],
                None,
            )
            return response(
                201, f"Object {args['object_name']} copied successfully.")
        except Exception as e:
            current_app.logger.error(f"{e}", exc_info=args["debug"])
            return response(500, f"{e}")