summaryrefslogtreecommitdiff
path: root/docs/guides
diff options
context:
space:
mode:
authorMax Wu2016-11-27 10:54:00 +0800
committerGitHub2016-11-27 10:54:00 +0800
commitbd3d4958e43a8437e45113354059cf41dacda995 (patch)
tree8b1b08557a7caa516609dbb1f0b1a82d0b47d92a /docs/guides
parent76a6190dacae691968dc3baa7dd86696ac7bbc1e (diff)
parent1a4f3950e6d03797beb79c63a3e6f071d8298c17 (diff)
Merge pull request #248 from hackmdio/file-upload-options
Support other options for image uploading
Diffstat (limited to 'docs/guides')
-rw-r--r--docs/guides/images/s3-image-upload/bucket-policy-editor.pngbin0 -> 54641 bytes
-rw-r--r--docs/guides/images/s3-image-upload/bucket-property.pngbin0 -> 71762 bytes
-rw-r--r--docs/guides/images/s3-image-upload/create-bucket.pngbin0 -> 70260 bytes
-rw-r--r--docs/guides/images/s3-image-upload/custom-policy.pngbin0 -> 55804 bytes
-rw-r--r--docs/guides/images/s3-image-upload/iam-user.pngbin0 -> 91526 bytes
-rw-r--r--docs/guides/images/s3-image-upload/review-policy.pngbin0 -> 100067 bytes
-rw-r--r--docs/guides/s3-image-upload.md81
7 files changed, 81 insertions, 0 deletions
diff --git a/docs/guides/images/s3-image-upload/bucket-policy-editor.png b/docs/guides/images/s3-image-upload/bucket-policy-editor.png
new file mode 100644
index 00000000..d5f4427f
--- /dev/null
+++ b/docs/guides/images/s3-image-upload/bucket-policy-editor.png
Binary files differ
diff --git a/docs/guides/images/s3-image-upload/bucket-property.png b/docs/guides/images/s3-image-upload/bucket-property.png
new file mode 100644
index 00000000..9f4dc828
--- /dev/null
+++ b/docs/guides/images/s3-image-upload/bucket-property.png
Binary files differ
diff --git a/docs/guides/images/s3-image-upload/create-bucket.png b/docs/guides/images/s3-image-upload/create-bucket.png
new file mode 100644
index 00000000..925f0926
--- /dev/null
+++ b/docs/guides/images/s3-image-upload/create-bucket.png
Binary files differ
diff --git a/docs/guides/images/s3-image-upload/custom-policy.png b/docs/guides/images/s3-image-upload/custom-policy.png
new file mode 100644
index 00000000..01c570cd
--- /dev/null
+++ b/docs/guides/images/s3-image-upload/custom-policy.png
Binary files differ
diff --git a/docs/guides/images/s3-image-upload/iam-user.png b/docs/guides/images/s3-image-upload/iam-user.png
new file mode 100644
index 00000000..b26be122
--- /dev/null
+++ b/docs/guides/images/s3-image-upload/iam-user.png
Binary files differ
diff --git a/docs/guides/images/s3-image-upload/review-policy.png b/docs/guides/images/s3-image-upload/review-policy.png
new file mode 100644
index 00000000..7173788a
--- /dev/null
+++ b/docs/guides/images/s3-image-upload/review-policy.png
Binary files differ
diff --git a/docs/guides/s3-image-upload.md b/docs/guides/s3-image-upload.md
new file mode 100644
index 00000000..3d6259b9
--- /dev/null
+++ b/docs/guides/s3-image-upload.md
@@ -0,0 +1,81 @@
+# Guide - Setup HackMD S3 image upload
+
+1. Go to [AWS S3 console](https://console.aws.amazon.com/s3/home) and create a new bucket.
+
+ ![create-bucket](images/s3-image-upload/create-bucket.png)
+
+2. Click on bucket, select **Properties** on the side panel, and find **Permission** section. Click **Edit bucket policy**.
+
+ ![bucket-property](images/s3-image-upload/bucket-property.png)
+
+3. Enter the following policy, replace `bucket_name` with your bucket name:
+
+ ![bucket-policy-editor](images/s3-image-upload/bucket-policy-editor.png)
+
+ ```json
+ {
+ "Version": "2012-10-17",
+ "Statement": [
+ {
+ "Effect": "Allow",
+ "Principal": "*",
+ "Action": "s3:GetObject",
+ "Resource": "arn:aws:s3:::bucket_name/uploads/*"
+ }
+ ]
+ }
+ ```
+
+4. Go to IAM console and create a new IAM user. Remember your user credentials(`key`/`access token`)
+
+5. Enter user page, select **Permission** tab, look at **Inline Policies** section, and click **Create User Policy**
+
+ ![iam-user](images/s3-image-upload/iam-user.png)
+
+6. Select **Custom Policy**
+
+ ![custom-policy](images/s3-image-upload/custom-policy.png)
+
+7. Enter the following policy, replace `bucket_name` with your bucket name:
+
+ ![review-policy](images/s3-image-upload/review-policy.png)
+
+ ```json
+ {
+ "Version": "2012-10-17",
+ "Statement": [
+ {
+ "Effect": "Allow",
+ "Action": [
+ "s3:*"
+ ],
+ "Resource": [
+ "arn:aws:s3:::bucket_name/uploads/*"
+ ]
+ }
+ ]
+ }
+ ```
+
+8. Edit `config.json` and set following keys:
+
+ ```javascript
+ {
+ "production": {
+ ...
+ "imageUploadType": "s3",
+ "s3": {
+ "accessKeyId": "YOUR_S3_ACCESS_KEY_ID",
+ "secretAccessKey": "YOUR_S3_ACCESS_KEY",
+ "region": "YOUR_S3_REGION", // example: ap-northeast-1
+ "bucket": "YOUR_S3_BUCKET_NAME"
+ }
+ }
+ }
+ ```
+
+9. In additional to edit `config.json` directly, you could also try [environment variable](https://github.com/hackmdio/hackmd#environment-variables-will-overwrite-other-server-configs).
+
+## Related Tools
+
+* [AWS Policy Generator](http://awspolicygen.s3.amazonaws.com/policygen.html)