func (client *Client) DeleteObjectsWithPrefixWithContext(ctx context.Context, bucketName, prefix string, put2stash bool) error {
	listObjectsRequest := &ListObjectsRequest{
		BucketName: bucketName,
		Prefix:     prefix,
		Delimiter:  "",
		MaxKeys:    DefaultListObjectsMaxKeys,
	}

	objectListing, err := client.ListObjectsWithContext(ctx, listObjectsRequest)
	if err != nil {
		return err
	}

	for {
		names := make([]string, 0)
		for _, o := range objectListing.ObjectSummaries {
			names = append(names, o.ObjectName)
		}

		err = client.DeleteObjectsWithContext(ctx, bucketName, names, put2stash)
		if err != nil {
			return err
		}

		if !objectListing.Truncated {
			break
		}

		objectListing, err = client.ListObjectsNextBatchWithContext(ctx, objectListing)
		if err != nil {
			return err
		}
	}

	return nil
}
// DeleteObjectsWithPrefixWithContext will delete all objects with prefix of prefix with context controlling
DeleteObjectsWithPrefixWithContext will delete all objects with prefix of prefix with context controlling
// DeleteObjectsWithPrefixWithContext will delete all objects with prefix of prefix with context controlling
func (client *Client) DeleteObjectsWithPrefixWithContext(ctx context.Context, bucketName, prefix string, put2stash bool) error {
	listObjectsRequest := &ListObjectsRequest{
		BucketName: bucketName,
		Prefix:     prefix,
		Delimiter:  "",
		MaxKeys:    DefaultListObjectsMaxKeys,
	}
	objectListing, err := client.ListObjectsWithContext(ctx, listObjectsRequest)
	if err != nil {
		return err
	}
	for {
		names := make([]string, 0)
		for _, o := range objectListing.ObjectSummaries {
			names = append(names, o.ObjectName)
		}
		err = client.DeleteObjectsWithContext(ctx, bucketName, names, put2stash)
		if err != nil {
			return err
		}
		if !objectListing.Truncated {
			break
		}
		objectListing, err = client.ListObjectsNextBatchWithContext(ctx, objectListing)
		if err != nil {
			return err
		}
	}
	return nil
}
func ( client * Client ) DeleteObjectsWithPrefixWithContext ( ctx context . Context , bucketName , prefix string , put2stash bool ) error { listObjectsRequest := & ListObjectsRequest { BucketName : bucketName , Prefix : prefix , Delimiter : " " , MaxKeys : DefaultListObjectsMaxKeys , } objectListing , err := client . ListObjectsWithContext ( ctx , listObjectsRequest ) if err != nil { return err } for { names := make ( [ ] string , 0 ) for _ , o := range objectListing . ObjectSummaries { names = append ( names , o . ObjectName ) } err = client . DeleteObjectsWithContext ( ctx , bucketName , names , put2stash ) if err != nil { return err } if ! objectListing . Truncated { break } objectListing , err = client . ListObjectsNextBatchWithContext ( ctx , objectListing ) if err != nil { return err } } return nil }
DeleteObjectsWithPrefixWithContext will delete all objects with prefix of prefix with context controlling
DeleteObjectsWithPrefixWithContext will delete all objects with prefix of prefix with context controlling