Google Cloud Storage
This guide walks you through connecting Sunshine Cloud Storage to Google Cloud Storage (GCS).
What You Need
- A Google Cloud account with a project
- A Cloud Storage bucket
- A service account with a JSON key file
Step 1: Create a Bucket
In the Google Cloud Console, go to Cloud Storage > Buckets and click Create. Choose a name and a location. For access control, select Fine-grained (not Uniform). Fine-grained access allows Sunshine to make full-size images private while keeping thumbnails public.
For full details, see Google's documentation on creating buckets.
Step 2: Create a Service Account
Go to IAM & Admin > Service Accounts and create a new service account. Grant it the Storage Object Admin role on your project (or on the specific bucket if you prefer tighter permissions).
After creating the service account, go to its Keys tab, click Add Key > Create new key, and select JSON. Download the JSON key file — this contains your credentials.
For full details, see Google's documentation on creating service accounts and creating service account keys.
Step 3: Connect in Sunshine
- Go to Sunshine Photo Cart > Settings > Cloud Storage.
- Select Google Cloud Storage as the provider.
- Choose your connection method:
- Database — Paste the entire contents of your JSON key file into the Service Account JSON field. Then click Load Buckets and select your bucket.
- wp-config.php (recommended) — Add the provided code snippet to your
wp-config.phpfile, including the JSON key contents. - Click Test Connection to verify everything works.
wp-config.php Example
define( 'SUNSHINE_CLOUD_STORAGE_SETTINGS', serialize( array(
'provider' => 'google-cloud',
'gcs-json' => '{"type":"service_account","project_id":"my-project",...}',
'bucket' => 'my-bucket-name',
) ) );
Learn how to add this custom code to your WordPress website
Paste the full contents of your JSON key file as the gcs-json value, all on one line.
ACL Configuration
Google Cloud Storage buckets can use either Uniform or Fine-grained access control.
- Fine-grained (recommended) — Sunshine can set individual files as private or public. Full-size gallery images are private and served through signed URLs.
- Uniform — All files in the bucket share the same access level. Sunshine still works but can't make full-size images private.
If you see an ACL warning after testing your connection, go to your bucket > Permissions > Access Control and switch from Uniform to Fine-grained.
CORS Configuration
If images aren't loading in the WordPress admin but work fine on the frontend of your site, your bucket likely needs CORS (Cross-Origin Resource Sharing) headers. This allows the browser to load images from Google Cloud Storage when you're managing galleries in WordPress.
In the Google Cloud Console, go to Cloud Storage > Buckets, select your bucket, then go to the Configuration tab. Under Cross-origin resource sharing (CORS), click Edit and add a rule:
- Origin:
* - Methods:
GET,HEAD - Response headers:
* - Max age:
86400
Alternatively, you can set CORS using the gcloud CLI. Create a file called cors.json:
[
{
"origin": ["*"],
"method": ["GET", "HEAD"],
"responseHeader": ["*"],
"maxAgeSeconds": 86400
}
]
Learn how to add this custom code to your WordPress website
Then run:
gcloud storage buckets update gs://YOUR_BUCKET_NAME --cors-file=cors.json
Learn how to add this custom code to your WordPress website
Troubleshooting
"Could not load the default credentials"
Make sure you pasted the complete JSON key file contents. The JSON must include all fields (type, project_id, private_key_id, private_key, client_email, etc.).
Permission denied
Verify your service account has the Storage Object Admin role. If you scoped the role to a specific bucket, make sure it matches the bucket you selected in Sunshine.
Bucket not appearing in list
Make sure your service account has the Storage Admin role at the project level (needed to list buckets). Alternatively, you can store the bucket name in wp-config.php and skip the bucket selector.
Still need help?
If you have not yet found your answer in the documentation articles, please contact support