qoomon / aws-s3-bucket-browser

Single page application to browse AWS S3 bucket content
https://qoomon.github.io/aws-s3-bucket-browser/index.html?bucket=https://s3.amazonaws.com/spacenet-dataset#
MIT License
246 stars 85 forks source link

Google cloud storage support? #24

Closed atishpatel closed 2 years ago

atishpatel commented 2 years ago

This project is super cool!

Is there a way you can add support for google cloud storage? It also returns a xml same as s3 but idk how to configure this to work with Google storage

qoomon commented 2 years ago

If you can give my some details about the api I could see what I can do?

atishpatel commented 2 years ago

Sure. Here is the example i'm working with:

URL example: https://storage.googleapis.com/akash-wedding/ xml from that url

<ListBucketResult xmlns="http://doc.s3.amazonaws.com/2006-03-01">
    <Name>akash-wedding</Name>
    <Prefix/>
    <Marker/>
    <IsTruncated>false</IsTruncated>
    <Contents>
        <Key>E01BAFDEXUP-UFRAMRNN8-723b36c3b070-512.jpeg</Key>
        <Generation>1636601016857461</Generation>
        <MetaGeneration>1</MetaGeneration>
        <LastModified>2021-11-11T03:23:36.858Z</LastModified>
        <ETag>"6de7054bf1bad76ab689d6e50c82a822"</ETag>
        <Size>25577</Size>
    </Contents>
    <Contents>
        <Key>index.html</Key>
        <Generation>1636609147942859</Generation>
        <MetaGeneration>1</MetaGeneration>
        <LastModified>2021-11-11T05:39:07.951Z</LastModified>
        <ETag>"32a46bdf3195860be43b0f0222950af1"</ETag>
        <Size>22487</Size>
    </Contents>
</ListBucketResult>

index file example url: https://storage.googleapis.com/akash-wedding/index.html

qoomon commented 2 years ago

I found the problem. You changed rootPrefix: '' to rootPrefix: undefined, but undefined is not handled it needs to bo an empty string for no prefix. Just change it back to the default '' and it should work.

Anyway I'll add some undefined handling as well.

qoomon commented 2 years ago

Hope that helps.

qoomon commented 2 years ago

During debugging your script, I also found a bug by accident, so thanks for your question :-)

I fixed an unnecessary second api call for each navigation interaction.

qoomon commented 2 years ago

I fixed an other bug regarding generating file location url. Feel free to use the latest version (1.7.3) of the bucket explorer index.html

qoomon commented 2 years ago

if I execute following commands in the developer console at your index.html it's working and your file is listed as expected.

config.bucketUrl = config.bucketUrl.replace(/\/*$/,'') ; // if ending in '/' file location url is invalid, fixed in version 1.7.3
config.bucketMaskUrl = undefined; // don't set bucketMaskUrl
config.rootPrefix = ''; // can't be undefined, fixed in version 1.7.3
atishpatel commented 2 years ago

That works! Thank you! 🙏