func Zip(
	ctx context.Context,
	readBucket storage.ReadBucket,
	writer io.Writer,
	compressed bool,
) (retErr error) {
	zipWriter := zip.NewWriter(writer)
	defer func() {
		retErr = multierr.Append(retErr, zipWriter.Close())
	}()
	return storage.WalkReadObjects(
		ctx,
		readBucket,
		"",
		func(readObject storage.ReadObject) error {
			method := zip.Store
			if compressed {
				method = zip.Deflate
			}
			header := &zip.FileHeader{
				Name:   readObject.Path(),
				Method: method,
			}
			writer, err := zipWriter.CreateHeader(header)
			if err != nil {
				return err
			}
			_, err = io.Copy(writer, readObject)
			return err
		},
	)
}
// Zip zips the given bucket to the writer.
//
// Only regular files are added to the writer.
Zip zips the given bucket to the writer.

Only regular files are added to the writer.
// Zip zips the given bucket to the writer . // // Only regular files are added to the writer .
func Zip(
	ctx context.Context,
	readBucket storage.ReadBucket,
	writer io.Writer,
	compressed bool,
) (retErr error) {
	zipWriter := zip.NewWriter(writer)
	defer func() {
		retErr = multierr.Append(retErr, zipWriter.Close())
	}()
	return storage.WalkReadObjects(
		ctx,
		readBucket,
		"",
		func(readObject storage.ReadObject) error {
			method := zip.Store
			if compressed {
				method = zip.Deflate
			}
			header := &zip.FileHeader{
				Name:   readObject.Path(),
				Method: method,
			}
			writer, err := zipWriter.CreateHeader(header)
			if err != nil {
				return err
			}
			_, err = io.Copy(writer, readObject)
			return err
		},
	)
}
func Zip ( ctx context . Context , readBucket storage . ReadBucket , writer io . Writer , compressed bool , ) ( retErr error ) { zipWriter := zip . NewWriter ( writer ) defer func ( ) { retErr = multierr . Append ( retErr , zipWriter . Close ( ) ) } ( ) return storage . WalkReadObjects ( ctx , readBucket , " " , func ( readObject storage . ReadObject ) error { method := zip . Store if compressed { method = zip . Deflate } header := & zip . FileHeader { Name : readObject . Path ( ) , Method : method , } writer , err := zipWriter . CreateHeader ( header ) if err != nil { return err } _ , err = io . Copy ( writer , readObject ) return err } , ) }
Zip zips the given bucket to the writer.
Zip zips the given bucket to the writer .