I have quite extensively modified the code so that it will work in the following way:

- Changed the wrapper to work with "gcs://" protocol rather than using one that has a bucket name embedded.
- Read bucket name from the setting file.
- Ability to read GCP service credential json from file system for authentication.
- Ability to specify the root folder path of the bucket that you want to use in the admin form.
- Removed db read/write for file info in order to have direct access to GCS bucket for file info.
- Created a image render function in module file that is used by the request to render an image by
setting the right headers such as content type and cache control.
- Within the admin form, validate that the given service account has right set of permissions on the folders in the bucket.

If these can be something that would benefit the community by contributing, please let me know the right way to do so.
I will be glad to submit the code.

CommentFileSizeAuthor
#3 single-bucket-gcs-3077038-3.patch34.04 KBken.evers

Comments

ken.evers created an issue. See original summary.

jonloh’s picture

- Changed the wrapper to work with "gcs://" protocol rather than using one that has a bucket name embedded.

The original author of this module did this way so that each image field can be customised to a different bucket, just in case you need it, which I find it quite a good idea. Hence I didn't remove in from the 2.x version.

- Removed db read/write for file info in order to have direct access to GCS bucket for file info.

Read/Writing to DB is usually faster and it's acting like a cache, especially when your website is a high traffic site.

---

You can make a patch by using git diff - Refer to this here: https://www.drupal.org/node/707484. Once you have the .patch file, attach it here and we'll have a review to see if it's all good to be merged.

Thanks for your contribution to make this module better ;)

ken.evers’s picture

StatusFileSize
new34.04 KB

Here is the patch file as requested.

Again, this only works with single bucket in mind.
Also I didn't try to merge with the existing code where it is utilizing the DB for file info.
Please do so as you see fit.