NOTE: For Version 3 of the AWS SDK for PHP, please see the V3 User Guide and V3 API Reference.

# Class AbstractSyncBuilder

### Direct known subclasses

`Aws\S3\Sync\DownloadSyncBuilder`, `Aws\S3\Sync\UploadSyncBuilder`

Abstract
Namespace: Aws\S3\Sync
Located at Aws/S3/Sync/AbstractSyncBuilder.php

## Methods summary

- `public static` `getInstance ( )`
- `public` `setBucket ( string $bucket )`

  Set the bucket to use with the sync

- `public` `setClient ( Aws\S3\S3Client $client )`

  Set the Amazon S3 client object that will send requests

- `public` `setSourceIterator ( Iterator $iterator )`

  Set a custom iterator that returns \SplFileInfo objects for the source data

- `public` `setSourceFilenameConverter ( Aws\S3\Sync\FilenameConverterInterface $converter )`

  Set a custom object key provider instead of building one internally

- `public` `setTargetFilenameConverter ( Aws\S3\Sync\FilenameConverterInterface $converter )`

  Set a custom object key provider instead of building one internally

- `public` `setBaseDir ( string $baseDir )`

  Set the base directory of the files being transferred. The base directory is removed from each file path before converting the file path to an object key or vice versa.

- `public` `setKeyPrefix ( string $keyPrefix )`

  Specify a prefix to prepend to each Amazon S3 object key or the prefix where object are stored in a bucket

- `public` `setDelimiter ( string $delimiter )`

  Specify the delimiter used for the targeted filesystem (default delimiter is "/")

- `public` `setOperationParams ( array $params )`

  Specify an array of operation parameters to apply to each operation executed by the sync object

- `public` `setConcurrency ( int $concurrency )`

  Set the number of files that can be transferred concurrently

- `public` `force ( bool $force = false )`

  Set to true to force transfers even if a file already exists and has not changed

- `public` `enableDebugOutput ( bool|resource $enabledOrResource = true )`

  Enable debug mode

- `public` `addRegexFilter ( string $search )`

  Add a filename filter that uses a regular expression to filter out files that you do not wish to transfer.

- `public` `build ( )`

  Builds a UploadSync or DownloadSync object

- `abstract protected` `specificBuild ( )`

  Hook to implement in subclasses

- `abstract protected` `getTargetIterator ( )`
- `abstract protected` `getDefaultSourceConverter ( )`
- `abstract protected` `getDefaultTargetConverter ( )`
- `abstract protected` `addDebugListener ( Aws\S3\Sync\AbstractSync $sync, resource $resource )`

  Add a listener to the sync object to output debug information while transferring

- `protected` `validateRequirements ( )`

  Validate that the builder has the minimal requirements

- `protected` `assertFileIteratorSet ( )`

  Ensure that the base file iterator has been provided

- `protected` `filterIterator ( Iterator $iterator )`

  Wraps a generated iterator in a filter iterator that removes directories

- `protected` `addCustomParamListener ( Guzzle\Common\HasDispatcherInterface $sync )`

  Add the custom param listener to a transfer object

- `protected` `createS3Iterator ( )`

  Create an Amazon S3 file iterator based on the given builder settings

## Methods detail

# `public static static`
`getInstance( )`

#### Returns

`static`
# `public mixed`
`setBucket( string $bucket )`

Set the bucket to use with the sync

#### Parameters

$bucket
  `string`
  $bucket Amazon S3 bucket name

#### Returns

`mixed`
$this
# `public mixed`
`setClient( `Aws\S3\S3Client` $client )`

Set the Amazon S3 client object that will send requests

#### Parameters

$client
  ``Aws\S3\S3Client``
  $client Amazon S3 client

#### Returns

`mixed`
$this
# `public mixed`
`setSourceIterator( `Iterator` $iterator )`

Set a custom iterator that returns \SplFileInfo objects for the source data

#### Parameters

$iterator
  ``Iterator``
  $iterator

#### Returns

`mixed`
$this
# `public mixed`
`setSourceFilenameConverter( `Aws\S3\Sync\FilenameConverterInterface` $converter )`

Set a custom object key provider instead of building one internally

#### Parameters

$converter
  `FileNameConverterInterface`
  $converter Filename to object key provider

#### Returns

`mixed`
$this
# `public mixed`
`setTargetFilenameConverter( `Aws\S3\Sync\FilenameConverterInterface` $converter )`

Set a custom object key provider instead of building one internally

#### Parameters

$converter
  `FileNameConverterInterface`
  $converter Filename to object key provider

#### Returns

`mixed`
$this
# `public mixed`
`setBaseDir( string $baseDir )`

Set the base directory of the files being transferred. The base directory is removed from each file path before converting the file path to an object key or vice versa.

#### Parameters

$baseDir
  `string`
  $baseDir Base directory, which will be deleted from each uploaded object key

#### Returns

`mixed`
$this
# `public mixed`
`setKeyPrefix( string $keyPrefix )`

Specify a prefix to prepend to each Amazon S3 object key or the prefix where object are stored in a bucket

Can be used to upload files to a pseudo sub-folder key or only download files from a pseudo sub-folder

#### Parameters

$keyPrefix
  `string`
  $keyPrefix Prefix for each uploaded key

#### Returns

`mixed`
$this
# `public mixed`
`setDelimiter( string $delimiter )`

Specify the delimiter used for the targeted filesystem (default delimiter is "/")

#### Parameters

$delimiter
  `string`
  $delimiter Delimiter to use to separate paths

#### Returns

`mixed`
$this
# `public mixed`
`setOperationParams( array $params )`

Specify an array of operation parameters to apply to each operation executed by the sync object

#### Parameters

$params
  `array`
  $params Associative array of PutObject (upload) GetObject (download) parameters

#### Returns

`mixed`
$this
# `public mixed`
`setConcurrency( integer $concurrency )`

Set the number of files that can be transferred concurrently

#### Parameters

$concurrency
  `integer`
  $concurrency Number of concurrent transfers

#### Returns

`mixed`
$this
# `public mixed`
`force( boolean $force = false )`

Set to true to force transfers even if a file already exists and has not changed

#### Parameters

$force
  `boolean`
  $force Set to true to force transfers without checking if it has changed

#### Returns

`mixed`
$this
# `public mixed`
`enableDebugOutput( boolean|resource $enabledOrResource = true )`

Enable debug mode

#### Parameters

$enabledOrResource
  `boolean|resource`
  $enabledOrResource Set to true or false to enable or disable debug output. Pass an opened fopen resource to write to instead of writing to standard out.

#### Returns

`mixed`
$this
# `public mixed`
`addRegexFilter( string $search )`

Add a filename filter that uses a regular expression to filter out files that you do not wish to transfer.

#### Parameters

$search
  `string`
  $search Regular expression search (in preg_match format). Any filename that matches this regex will not be transferred.

#### Returns

`mixed`
$this
# `public `Aws\S3\Sync\AbstractSync``
`build( )`

Builds a UploadSync or DownloadSync object

#### Returns

``Aws\S3\Sync\AbstractSync``
# `abstract protected `Aws\S3\Sync\AbstractSync``
`specificBuild( )`

Hook to implement in subclasses

#### Returns

``Aws\S3\Sync\AbstractSync``
# `abstract protected `Iterator``
`getTargetIterator( )`

#### Returns

``Iterator``
# `abstract protected `Aws\S3\Sync\FilenameConverterInterface``
`getDefaultSourceConverter( )`

#### Returns

``Aws\S3\Sync\FilenameConverterInterface``
# `abstract protected `Aws\S3\Sync\FilenameConverterInterface``
`getDefaultTargetConverter( )`

#### Returns

``Aws\S3\Sync\FilenameConverterInterface``
# `abstract protected`
`addDebugListener( `Aws\S3\Sync\AbstractSync` $sync, resource $resource )`

Add a listener to the sync object to output debug information while transferring

#### Parameters

$sync
  ``Aws\S3\Sync\AbstractSync``
  $sync Sync object to listen to
$resource
  `resource`
  $resource Where to write debug messages

# `protected`
`validateRequirements( )`

Validate that the builder has the minimal requirements

#### Throws

``Aws\Common\Exception\RuntimeException``
if the builder is not configured completely
# `protected`
`assertFileIteratorSet( )`

Ensure that the base file iterator has been provided

#### Throws

``Aws\Common\Exception\RuntimeException``
# `protected `Iterator``
`filterIterator( `Iterator` $iterator )`

Wraps a generated iterator in a filter iterator that removes directories

#### Parameters

$iterator
  ``Iterator``
  $iterator Iterator to wrap

#### Returns

``Iterator``

#### Throws

``Aws\Common\Exception\UnexpectedValueException``
# `protected`
`addCustomParamListener( `Guzzle\Common\HasDispatcherInterface` $sync )`

Add the custom param listener to a transfer object

#### Parameters

$sync
  ``Guzzle\Common\HasDispatcherInterface``
  $sync

# `protected `Aws\S3\Iterator\OpendirIterator``
`createS3Iterator( )`

Create an Amazon S3 file iterator based on the given builder settings

#### Returns

``Aws\S3\Iterator\OpendirIterator``

### Magic methods summary

## Properties summary

`protected `Iterator`` | $sourceIterator | # Iterator that returns SplFileInfo objects to upload
`protected `Aws\S3\S3Client`` | $client | # Amazon S3 client used to send requests
`protected string` | $bucket | # Bucket used with the transfer
`protected integer` | $concurrency | # Number of files that can be transferred concurrently
`protected array` | $params | # Custom parameters to add to each operation sent while transferring
`protected `Aws\S3\Sync\FilenameConverterInterface`` | $sourceConverter | #
`protected `Aws\S3\Sync\FilenameConverterInterface`` | $targetConverter | #
`protected string` | $keyPrefix | # Prefix at prepend to each Amazon S3 object key
`protected string` | $delimiter | # Directory separator for Amazon S3 keys
`protected string` | $baseDir | # Base directory to remove from each file path before converting to an object name or file name
`protected boolean` | $forcing | # Whether or not to only transfer modified or new files
`protected boolean` | $debug | # Whether or not debug output is enable