├── .gitignore ├── LICENSE ├── README.md ├── favicon.ico ├── index.html └── logo.png /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .idea/ 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Bengt Brodersen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AWS S3 Bucket Browser [![starline](https://starlines.qoo.monster/assets/qoomon/aws-s3-bucket-browser)](https://github.com/qoomon/starlines) 2 | 3 | ![-](favicon.ico) 4 | 5 | Single HTML file to browse AWS S3 buckets 6 | ## [Demo](https://qoomon.github.io/aws-s3-bucket-browser/index.html?bucket=https://s3.amazonaws.com/spacenet-dataset#) 7 | 8 | ## Features 9 | * Compatible Providers: [![GCP](https://www.google.com/s2/favicons?sz=16&domain=cloud.google.com)](https://cloud.google.com) [![IBM](https://www.google.com/s2/favicons?sz=16&domain=ibm.com)](https://ibm.com/cloud) [![DigitalOcean](https://www.google.com/s2/favicons?sz=161&domain=digitalocean.com)](https://digitalocean.com) 10 | * List all files in a table view 11 | * Treat and display `/` in keys as folders 12 | * Render preview for Markdown files 13 | * Show `Install` button for `manifest.plist` on iOS devices 14 | 15 | ## Installation 16 | 17 | #### Self-Hosted 18 |
19 | Click me 20 | 21 | * Just download [`index.html`](index.html) and upload it to your bucket. 22 | * Adjust [config](index.html#L8-L37) within `index.html` if needed, e.g. 23 | ```js 24 | const config = { 25 | title: 'Bucket Browser', // prefix value with `HTML> ` to render as html, see subtitle 26 | subtitle: 'HTML>made with ♥ by qoomon', // prefix value with `HTML> ` to render as html 27 | logo: 'https://qoomon.github.io/aws-s3-bucket-browser/logo.png', 28 | favicon: 'https://qoomon.github.io/aws-s3-bucket-browser/favicon.ico', 29 | primaryColor: '#167df0', 30 | 31 | bucketUrl: undefined, 32 | // If bucketUrl is undefined, this script tries to determine bucket Rest API URL from this file location itself. 33 | // This will only work for locations like these 34 | // * https://s3.amazonaws.com/BUCKET-NAME/index.html 35 | // * https://s3.BUCKET-REGION.amazonaws.com/BUCKET-NAME/index.html 36 | // * http://BUCKET-NAME.s3-website-BUCKET-REGION.amazonaws.com/index.html 37 | // * https://storage.googleapis.com/BUCKET-NAME/index.html 38 | // * https://BUCKET-NAME.s3-web.BUCKET-REGION.cloud-object-storage.appdomain.cloud/ 39 | // * https://BUCKET-NAME.BUCKET-REGION.digitaloceanspaces.com 40 | // * https://BUCKET-NAME.BUCKET-REGION.cdn.digitaloceanspaces.com 41 | // If bucketUrl is set manually, ensure this is the bucket Rest API URL, e.g. 42 | // * https://s3.amazonaws.com/BUCKET-NAME 43 | // * https://storage.googleapis.com/BUCKET-NAME 44 | // The URL should return an XML document with as root element. 45 | rootPrefix: undefined, // e.g. 'subfolder/' 46 | keyExcludePatterns: [/^index\.html$/], // matches againt object key relative to rootPrefix 47 | pageSize: 50, 48 | 49 | bucketMaskUrl: undefined, 50 | // If bucketMaskUrl is set file urls will be changed from ${bucketUrl}/${file} to ${bucketMaskUrl}/${file} 51 | // bucketMaskUrl: 'https://example.org' 52 | // => https://example.org/foo/bar.txt 53 | // bucketMaskUrl: document.location.origin 54 | // => ${document.location.origin}/foo/bar.txt 55 | 56 | defaultOrder: 'name-asc' // (name|size|dateModified)-(asc|desc) 57 | } 58 | ``` 59 | * ##### ⚠️ Ensure Bucket Permissions 60 | * Go to `https://s3.console.aws.amazon.com/s3/buckets//?tab=permissions` 61 | * Grant public read permission by `Access Control List` or `Bucket Policy` 62 | * Access Control List 63 | * Enable `List objects` for `Everyone` 64 | * Bucket Policy 65 | ```json 66 | { 67 | "Version": "2012-10-17", 68 | "Statement": [ 69 | { 70 | "Sid": "PublicRead", 71 | "Principal": "*", 72 | "Effect": "Allow", 73 | "Action": [ 74 | "s3:ListBucket", 75 | "s3:GetObject" 76 | ], 77 | "Resource": [ 78 | "arn:aws:s3:::", 79 | "arn:aws:s3:::/*" 80 | ] 81 | } 82 | ] 83 | } 84 | ``` 85 | * ##### ⚠️ Ensure Bucket CORS 86 | * Depending on your setup you may need to ensure following `CORS Configuration` 87 | * Go to `https://s3.console.aws.amazon.com/s3/buckets//?tab=permissions` 88 | * Grant Cross Origin Access by following `CORS Configuration`, replace `http://www.example.com` by your address of bucket browser `index.html` 89 | * e.g `http://example.s3-website-eu-central-1.amazonaws.com/index.html` 90 | ```json 91 | [ 92 | { 93 | "AllowedHeaders": [ 94 | "*" 95 | ], 96 | "AllowedMethods": [ 97 | "GET" 98 | ], 99 | "AllowedOrigins": [ 100 | "http://www.example.com", 101 | "https://BUCKET-NAME.s3.amazonaws.com", 102 | "https://s3.BUCKET-REGION.amazonaws.com/BUCKET-NAME", 103 | ], 104 | "ExposeHeaders": [ 105 | "x-amz-server-side-encryption", 106 | "x-amz-request-id", 107 | "x-amz-id-2" 108 | ], 109 | "MaxAgeSeconds": 3000 110 | } 111 | ] 112 | ``` 113 | * Open `/index.html` in your browser. 114 | 115 |
116 | 117 | #### Hosted 118 |
119 | Click me 120 | 121 | * ##### ⚠️ Ensure Bucket Permissions 122 | * see [Self-Hosted](#self-hosted) 123 | * ##### ⚠️ Ensure Bucket CORS 124 | * see [Self-Hosted](#self-hosted) 125 | * Open hosted `index.html` in your browser and provide bucket url as `bucket` request parameter 126 | * `${INDEX_FILE_LOCATION}?bucket=${S3_BUCKET_URL}` 127 | * e.g. [`https://qoomon.github.io/aws-s3-bucket-browser/index.html?bucket=https://s3.eu-west-1.amazonaws.com/data.openspending.org`](https://qoomon.github.io/aws-s3-bucket-browser/index.html?bucket=https://s3.eu-west-1.amazonaws.com/data.openspending.org) 128 | 129 |
130 | 131 | ### CloudFront Setup 132 |
133 | Click me 134 | 135 | If you use CloudFront in front of your S3 bucket ensure following CloudFront settings. 136 | - Allowed/Cached HTTP Methods: `GET`, `HEAD`, `OPTIONS` 137 | - Cached Based on Selected Headers: `Whitelist` 138 | - `Access-Control-Request-Headers` 139 | - `Access-Control-Request-Method` 140 | - `Origin` 141 | - Query String Forwarding and Caching: `Forward all` 142 | 143 |
144 | 145 | ### IBM Cloud Object Storage Setup 146 |
147 | Click me 148 | 149 | IBM Cloud Object storage only supports virtual host-style addressing, i.e. `https://s3-web..cloud-object-storage.appdomain.cloud/` for static website hosting. Otherwise follow the instructions 150 | in this [tutorial](https://cloud.ibm.com/docs/cloud-object-storage?topic=cloud-object-storage-static-website-tutorial) to configure your bucket. In addition, you may need to [configure CORS](https://cloud.ibm.com/docs/cloud-object-storage?topic=cloud-object-storage-curl#curl-new-cors) for your bucket. 151 | 152 | ```xml 153 | 154 | 155 | * 156 | GET 157 | * 158 | 159 | 160 | ``` 161 | 162 |
163 | -------------------------------------------------------------------------------- /favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qoomon/aws-s3-bucket-browser/5e836768f92beae68057b6fbb622cf0ec5666bbb/favicon.ico -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 44 | 45 | 46 | 47 | 48 | Bucket Browser 49 | 50 | 53 | 56 | 59 | 60 | 63 | 64 | 67 | 68 | 71 | 72 | 75 | 76 | 79 | 80 | 81 | 82 | 239 | 240 | 241 | 242 | 243 | 244 | 493 | 494 | 495 | 538 | 539 | 540 | 541 | 549 | 574 | 575 | 576 | 577 | 610 | 611 | 612 | 695 | 696 | 697 | 1031 | 1032 | 1033 | 1034 | -------------------------------------------------------------------------------- /logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qoomon/aws-s3-bucket-browser/5e836768f92beae68057b6fbb622cf0ec5666bbb/logo.png --------------------------------------------------------------------------------