|
| 1 | +# Google Cloud Storage Transfer Samples |
| 2 | + |
| 3 | +## Description |
| 4 | + |
| 5 | +All code in the snippets directory demonstrate how to invoke |
| 6 | +[Cloud Storage Trasfer][cloud-storage-transfer] from PHP. |
| 7 | + |
| 8 | +`src/quickstart.php` is a sample function to create and run a transfer job between two GCS buckets. |
| 9 | + |
| 10 | +[cloud-storage-transfer]: https://cloud.google.com/storage-transfer/docs/create-transfers |
| 11 | + |
| 12 | +## Setup: |
| 13 | + |
| 14 | +1. **Enable APIs** - [Enable the Storage Transfer Service API](https://console.cloud.google.com/flows/enableapi?apiid=storagetransfer.googleapis.com) |
| 15 | + and create a new project or select an existing project. |
| 16 | +2. **Download The Credentials** - Click "Go to credentials" after enabling the APIs. Click "New Credentials" |
| 17 | + and select "Service Account Key". Create a new service account, use the JSON key type, and |
| 18 | + select "Create". Once downloaded, set the environment variable `GOOGLE_APPLICATION_CREDENTIALS` |
| 19 | + to the path of the JSON key that was downloaded. |
| 20 | +3. **Clone the repo** and cd into this directory |
| 21 | + |
| 22 | + ```sh |
| 23 | + $ git clone https://github.com/GoogleCloudPlatform/php-docs-samples |
| 24 | + $ cd php-docs-samples/storagetransfer |
| 25 | + ``` |
| 26 | +4. **Install dependencies** via [Composer](http://getcomposer.org/doc/00-intro.md). |
| 27 | + Run `php composer.phar install` (if composer is installed locally) or `composer install` |
| 28 | + (if composer is installed globally). |
| 29 | + |
| 30 | + |
| 31 | +## Samples |
| 32 | + |
| 33 | +To run the Storage Transfer Samples, run any of the files in `src/` on the CLI: |
| 34 | + |
| 35 | +``` |
| 36 | +$ php src/quickstart.php |
| 37 | + |
| 38 | +Usage: quickstart.php $bucketName $sourceGcsBucketName $sinkGcsBucketName |
| 39 | + |
| 40 | + @param string $projectId The Project ID |
| 41 | + @param string $sourceGcsBucketName The Storage bucket name |
| 42 | + @param string $sinkGcsBucketName The Storage bucket name |
| 43 | +``` |
| 44 | +
|
| 45 | +
|
| 46 | +## The client library |
| 47 | +
|
| 48 | +This sample uses the [Cloud Storage Transfer Client Library for PHP][google-cloud-php-storage-transfer]. |
| 49 | +You can read the documentation for more details on API usage and use GitHub |
| 50 | +to [browse the source][google-cloud-php-source] and [report issues][google-cloud-php-issues]. |
| 51 | +
|
| 52 | +[google-cloud-php-storage-transfer]: https://cloud.google.com/php/docs/reference/cloud-storage-transfer/latest |
| 53 | +[google-cloud-php-source]: https://github.com/GoogleCloudPlatform/google-cloud-php |
| 54 | +[google-cloud-php-issues]: https://github.com/GoogleCloudPlatform/google-cloud-php/issues |
| 55 | +[google-cloud-sdk]: https://cloud.google.com/sdk/ |
| 56 | +
|
| 57 | +## Contributing changes |
| 58 | +
|
| 59 | +* See [CONTRIBUTING.md](../../CONTRIBUTING.md) |
| 60 | +
|
| 61 | +## Licensing |
| 62 | +
|
| 63 | +* See [LICENSE](../../LICENSE) |
0 commit comments