Skip to content

Commit eead4c1

Browse files
authored
Merge pull request #27 from adam-gray/master
Add support for IBM Cloud Object Storage
2 parents 97fef9e + 164e7c3 commit eead4c1

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Single HTML file to browse AWS S3 buckets
2323
// * https://s3.BUCKET-REGION.amazonaws.com/BUCKET-NAME/index.html
2424
// * http://BUCKET-NAME.s3-website-BUCKET-REGION.amazonaws.com/index.html
2525
// * https://storage.googleapis.com/BUCKET-NAME/index.html
26+
// * https://BUCKET-NAME.s3-web.BUCKET-REGION.cloud-object-storage.appdomain.cloud/
2627
// If bucketUrl is set manually, ensure this is the bucket Rest API URL, e.g.
2728
// * https://s3.BUCKET-REGION.amazonaws.com/BUCKET-NAME
2829
// * https://storage.googleapis.com/BUCKET-NAME
@@ -109,3 +110,20 @@ If you use CloudFront in upfront of your S3 bucket ensure following CloudFront s
109110
- `Access-Control-Request-Method`
110111
- `Origin`
111112
- Query String Forwarding and Caching: `Forward all`
113+
114+
### IBM Cloud Object Storage Setup
115+
IBM Cloud Object storage only supports virtual host-style addressing, i.e. `https://<bucket-name>s3-web.<region>.cloud-object-storage.appdomain.cloud/` for static website hosting. Otherwise follow the instructions
116+
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.
117+
118+
```
119+
<CORSConfiguration>
120+
<CORSRule>
121+
<AllowedOrigin>*</AllowedOrigin>
122+
<AllowedMethod>GET</AllowedMethod>
123+
<AllowedHeader>*</AllowedHeader>
124+
</CORSRule>
125+
</CORSConfiguration>
126+
```
127+
128+
A example deployment is available [here](https://s3-bucket-browser-demo.s3-web.us-south.cloud-object-storage.appdomain.cloud/).
129+

index.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
// * https://s3.BUCKET-REGION.amazonaws.com/BUCKET-NAME/index.html
1919
// * http://BUCKET-NAME.s3-website-BUCKET-REGION.amazonaws.com/index.html
2020
// * https://storage.googleapis.com/BUCKET-NAME/index.html
21+
// * https://BUCKET-NAME.s3-web.BUCKET-REGION.cloud-object-storage.appdomain.cloud/
2122
// If bucketUrl is set manually, ensure this is the bucket Rest API URL, e.g.
2223
// * https://s3.BUCKET-REGION.amazonaws.com/BUCKET-NAME
2324
// * https://storage.googleapis.com/BUCKET-NAME
@@ -298,6 +299,11 @@ <h2 class="subtitle">{{config.subtitle}}</h2>
298299
// check for urls like https://storage.googleapis.com/example-bucket/index.html
299300
match = config.bucketUrl.match(/(?<protocol>[^:]+):\/\/storage\.googleapis\.com\/(?<name>[^.]+)/)
300301
}
302+
if (!match) {
303+
type = 'IBM'
304+
// check for urls like http://example-bucket.s3-web.us-south.cloud-object-storage.appdomain.cloud/index.html
305+
match = config.bucketUrl.match(/(?<protocol>[^:]+):\/\/(?<name>[^.]+)\.s3-web\.(?<region>[^.]+)\.cloud-object-storage\.appdomain\.cloud/)
306+
}
301307

302308
if (match) {
303309
switch (type) {
@@ -307,6 +313,9 @@ <h2 class="subtitle">{{config.subtitle}}</h2>
307313
case 'GCP':
308314
config.bucketUrl = `${match.groups.protocol}://storage.googleapis.com/${match.groups.name}`
309315
break;
316+
case 'IBM':
317+
config.bucketUrl = `${match.groups.protocol}://${match.groups.name}.s3.${match.groups.region}.cloud-object-storage.appdomain.cloud/`
318+
break;
310319
}
311320
}
312321

0 commit comments

Comments
 (0)