3.2 KiB
Guide - Setup HedgeDoc S3 image upload to Google Cloud Storage
HedgeDoc has no direct/native support for storing images in Google Cloud Storage Buckets. However since Google provides interoperability with S3, the S3 integration can be used.
This guide will help you in getting things setup.
Setup the bucket
Create a bucket in Google Cloud Storage
- Create a new bucket within the Cloud Storage portal.
- Give it a name, select the region and type of storage (e.g. multi dual-region)
- In "Choose how to control access to objects" disable "Enforce public access prevention on this bucket"
Open the bucket to the public
In order to view the images uploaded to HedgeDoc the storage bucket needs to be set to public.
- Click the bucket you just created in the Cloud Storage portal.
- Go to the Permissions tab
- Scroll down to the Permissions section
- Click Grant Access
- Add
allusers
as principal - Give it role
Storage Object Viewer
to allow it to retrieve the roles
Setup interoperability & create Service Account
- Go to the interoperability tab in the Google Cloud Console
- Scroll down to "Access keys for service accounts" and click on "Create a key for a service account"
- Select "Create new account"
- Give it a name, e.g.
hedgedoc
- Select the
Storage Object Creator
role and select Add IAM Condition - Give it a name, e.g.
Restrict to bucket
- In Condition Builder:
- Condition type: Name
- Operator: Starts With
- Value:
projects/_/buckets/YOUR_BUCKET_NAME_HERE
- Skip the 3rd step (Grant users access to this service account)
- Click done
- Copy the Access Key and Secret to a text editor, we'll be using this later
Add permissions
-
Go to Roles within the IAM & Admin section in Google Cloud Console
-
Click Create Role
-
Give it a name (e.g.
Allow to view buckets
) and an id (e.g.bucket-viewer
) -
Click Add Permissions
-
In the filter (below the dropdown) type
storage.buckets.get
-
Check the box in front of the
storage.buckets.get
entry, click Add. -
Click Create
-
Go to IAM & Admin section and go to the IAM page
-
Find the user we created in the previous step and edit it
-
Click "Add another role" and select the role we just created
-
Select the role we just created and select Add IAM Condition
-
Give it a name, e.g.
Restrict to bucket
-
In Condition Builder:
- Condition type: Name
- Operator: Starts With
- Value:
projects/_/buckets/YOUR_BUCKET_NAME_HERE
-
Save it.
Configure HedgeDoc
Set the following environment variables (or the corresponding config.json values):
CMD_IMAGE_UPLOAD_TYPE="s3"
CMD_S3_ENDPOINT="https://storage.googleapis.com"
CMD_S3_ACCESS_KEY_ID="GOOG1EXXXXXXXXXX"
CMD_S3_SECRET_ACCESS_KEY="XXXXXXXXXX"
CMD_S3_BUCKET="your-bucket-name"
The access key and secret key are the values you received when you enabled the interoperability feature.
After restarting HedgeDoc you should now be able to add images to your pages.