flightlesstux / S3-Directory-Listing

Are you tired of the boring, generic S3 bucket listings? 🥱 Well, look no further! 😎
25 stars 8 forks source link

Amazing - just what I needed , just needed a tweak to work in eu-west-2 #1

Closed johnf-passiv closed 1 year ago

johnf-passiv commented 1 year ago

I've had to change two blocks in the s3.js file for this code to work in our AWS region:

function createDownloadLink(key) { const url = http://${bucketName}.s3-eu-west-2.amazonaws.com/${key}; const link = document.createElement('a'); link.href = url;

function listObjects(path) { const prefix = path ? prefix=${path}& : ''; const url = http://${bucketName}.s3-eu-west-2.amazonaws.com/?list-type=2&${prefix}delimiter=%2F;

flightlesstux commented 1 year ago

Hi @johnf-passiv,

Thank you so much for this issue. You don't need to update these two blocks. As I understand, you didn't read the README file : )

Just update const bucketName = 's3-directory-listing'; in the s3.js file on line 2. Here is the link:https://github.com/flightlesstux/S3-Directory-Listing/blob/main/s3.js#L2

Here is the example bucket URL: https://s3-directory-listing-issue-1.s3.amazonaws.com/index.html

You don't need/have to set any kind of region variable. It's all dynamic.

johnf-passiv commented 1 year ago

We operate in region eu-west-2 which seems to use a different url for the website than then us based zones

John

On Fri, 16 Jun 2023 at 23:41, Ercan @.***> wrote:

Hi @johnf-passiv https://github.com/johnf-passiv,

Thank you so much for this issue. You don't need to update these two blocks. As I understand, you didn't read the README file : )

Just update const bucketName = 's3-directory-listing'; in the s3.js file on line 2. Here is the link: https://github.com/flightlesstux/S3-Directory-Listing/blob/main/s3.js#L2

Here is the example bucket URL: https://s3-directory-listing-issue-1.s3.amazonaws.com/index.html

You don't need/have to set any kind of region variable. It's all dynamic.

— Reply to this email directly, view it on GitHub https://github.com/flightlesstux/S3-Directory-Listing/issues/1#issuecomment-1595408618, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZHUYWTPXAFZEHPGXKWLB4LXLTOLNANCNFSM6AAAAAAZJGXGLE . You are receiving this because you were mentioned.Message ID: @.***>

flightlesstux commented 1 year ago

@johnf-passiv,

There are two different types of URLs to access S3 Bucket.

You should declare the region in the URL for HTTP access: http://s3-directory-listing-issue-1.s3-website.eu-west-2.amazonaws.com/index.html

You shouldn't declare the region in the URL for HTTPS access: https://s3-directory-listing-issue-1.s3.amazonaws.com/index.html

I hope, it works!

johnf-passiv commented 1 year ago

Thanks for the update. I still had to update the s3.js file manually for this page to work: http://downloads.passivuk.com/

Are you suggesting your js file should already work for http in eu-west-2 ?

On Sat, 17 Jun 2023 at 14:44, Ercan @.***> wrote:

@johnf-passiv https://github.com/johnf-passiv,

There are two different types of URLs to access S3 Bucket.

You should declare the region in the URL for HTTP access: http://s3-directory-listing-issue-1.s3-website.eu-west-2.amazonaws.com/index.html

You shouldn't declare the region in the URL for HTTPS access: https://s3-directory-listing-issue-1.s3.amazonaws.com/index.html

I hope, it works!

— Reply to this email directly, view it on GitHub https://github.com/flightlesstux/S3-Directory-Listing/issues/1#issuecomment-1595764183, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZHUYWTVN3Q3NFTLPN3BTQDXLWYEPANCNFSM6AAAAAAZJGXGLE . You are receiving this because you were mentioned.Message ID: @.***>

--

NOTE: This E-Mail originates from Passiv UK Limited, Benyon House, Newbury, RG14 2PZ, UK

VAT Number: GB 688 8971 40. Registered No: 12929432. 

DISCLAIMER: The information in this E-Mail and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your system and notify the sender immediately. You should not retain, copy or use this E-Mail for any purpose, nor disclose all or any part of its content to any other person. Whilst we run antivirus software on Internet E-Mails, we are not liable for any loss or damage. The recipient is advised to run their own up to date antivirus software.

Thank you.

flightlesstux commented 1 year ago

Hi @johnf-passiv, I see, you s3.js file contains the code below and you just need to write your BUCKET NAME not any kind of domain or something else.

// S3 bucket name
const bucketName = 'downloads.passivuk.com';
johnf-passiv commented 1 year ago

the S3 bucket name is:

downloads.passivuk.com

I've done this so that dns requests are forwarded on and matched by route53 , it's the recommended way for static website hosting.

On Mon, 19 Jun 2023 at 15:48, Ercan @.***> wrote:

Hi @johnf-passiv https://github.com/johnf-passiv, I see, you s3.js file contains the code below and you just need to write your BUCKET NAME not any kind of domain or something else.

// S3 bucket name const bucketName = 'downloads.passivuk.com';

— Reply to this email directly, view it on GitHub https://github.com/flightlesstux/S3-Directory-Listing/issues/1#issuecomment-1597320593, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZHUYWRQH5HKQTB54WBULYTXMBRCRANCNFSM6AAAAAAZJGXGLE . You are receiving this because you were mentioned.Message ID: @.***>

--

NOTE: This E-Mail originates from Passiv UK Limited, Benyon House, Newbury, RG14 2PZ, UK

VAT Number: GB 688 8971 40. Registered No: 12929432. 

DISCLAIMER: The information in this E-Mail and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your system and notify the sender immediately. You should not retain, copy or use this E-Mail for any purpose, nor disclose all or any part of its content to any other person. Whilst we run antivirus software on Internet E-Mails, we are not liable for any loss or damage. The recipient is advised to run their own up to date antivirus software.

Thank you.