Adapter for Google APIs Client Library for PHP.
service_idThe service id of the\Google_Service_Storageto use. (required)bucket_nameThe name of the GCS bucket to use. (required)detect_content_type: iftruewill detect the content type for each file (defaulttrue)optionsA list of additional options passed to the adapter.directoryA directory to operate in. (default '')aclWhether the uploaded files should beprivateorpublic(defaultprivate)
You need to create a custom factory service which creates a \Google_Client and authorizes with the correct scopes
and then returns a \Google_Service_Storage class connected to the client class:
services:
app.google_cloud_storage.service:
class: \Google_Service_Storage
factory: [App\Factory\GoogleCloudStorageServiceFactory
factory_method: 'createService'
arguments:
-
# all the arguments needed like service account email and path to key.p12Once the service is set up use its key as the service_id in the gaufrette configuration:
# app/config/config.yml
knp_gaufrette:
adapters:
profile_photos:
google_cloud_storage:
service_id: 'app.google_cloud_storage.service'
bucket_name: 'images'
options:
directory: 'profile_photos'