auroraextensions / googlecloudstorage
Google Cloud Storage integration for Magento.
Installs: 6 499
Dependents: 0
Suggesters: 0
Security: 0
Stars: 15
Watchers: 3
Forks: 6
Open Issues: 4
Type:magento2-module
Requires
- php: ^7.2||^8.0
- auroraextensions/modulecomponents: ^100.1.0
- google/cloud-core: ~1.33.0
- google/cloud-storage: ~1.14.0
- google/crc32: ~0.1.0
- magento/framework: ^100||^101||^102||^103
- magento/module-media-storage: ^100||^101
- magento/module-store: ^100||^101
- psr/http-message: ~1.0
- psr/log: ~1.0
- symfony/console: ^2.7||^3.0||^4.0||^5.0
README
Description
Use Google Cloud Storage to store media assets in Magento.
Installation
We highly recommend installing via Composer for package management.
composer require auroraextensions/googlecloudstorage
Configuration
Once installed, update the environment configuration file. See env.php.sample for an example. The following information should be readily available:
- Google Cloud project ID
- Path to the Google Cloud service account JSON key file. See Service Account for more details.
- Google Cloud Storage bucket name
- Google Cloud Storage bucket region (if applicable)
Next, enable the module with the Magento autoloader.
php bin/magento module:enable AuroraExtensions_GoogleCloudStorage
Synchronization
You can initiate the bulk synchronization process through the Magento backend, just as you would with any other media storage configuration. Additionally, you can initiate the bulk synchronization process from the command line using the provided synchronization CLI command.
php bin/magento gcs:media:sync
IMPORTANT: This process can be very slow, especially if you have a lot of media files.
Service Account
For the purposes of authenticating with Google Cloud Platform, this module leverages the flexibility and ease of use provided by Google Cloud service accounts. Before moving forward, please make sure to complete the following:
- Create a Google Cloud service account with Storage Admin privileges. Once the service account is created, you will be prompted to download a JSON key file. Store this key file in a safe place.
- Install the service account JSON key file to the local or mounted filesystem with read-only permissions for the Magento user.
- Verify the following fields are set and correct in the environment configuration file (env.php):
- All required fields
- The Google Cloud project name is where the bucket exists
- The path to the Google Cloud service account JSON key file (e.g. /etc/gcs.json). Relative paths are assumed to be relative to the Magento root directory.
- [OPTIONAL] If you use the same bucket for multiple projects, you can specify a subdirectory to synchronize to inside the bucket. By default, it will synchronize to /.
For more information on Google Cloud service account keys, please see Creating and Managing Service Account Keys.
For an example configuration file, please see env.php.sample.
Troubleshooting
Given keyfile at path /path/to/magento was invalid
You need to create and install a service account key to authenticate with Google Cloud. See Service Account for specific details on Google Cloud service accounts.