Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't support AWS China Region url. #77

Open
dkstsh opened this issue Apr 9, 2020 · 2 comments
Open

Can't support AWS China Region url. #77

dkstsh opened this issue Apr 9, 2020 · 2 comments
Assignees

Comments

@dkstsh
Copy link

dkstsh commented Apr 9, 2020

When click the object in the explorer list, the open window was blank with wrong url format, like "bucketname.s3-cn-north-1.amazonaws.com/object". Maybe cause by AWS china region url format is different with global region. The object correct url format is "bucketname.s3.cn-north-1.amazonaws.com.cn/object".

Please fix it, Thanks.

@dkstsh
Copy link
Author

dkstsh commented Apr 9, 2020

fix it:
function object2hrefvirt(bucket, key) {
var enckey = key.split('/').map(function (x) {
return encodeURIComponent(x);
}).join('/');

    if (AWS.config.region === "us-east-1") {
        return document.location.protocol + '//' + bucket + '.s3.amazonaws.com/' + enckey;
    } 

** fix this else if (AWS.config.region === "cn-north-1") {
return document.location.protocol + '//' + bucket + '.s3.' + AWS.config.region + '.amazonaws.com.cn/' + enckey;
**

    } else {
        return document.location.protocol + '//' + bucket + '.s3-' + AWS.config.region + '.amazonaws.com/' + enckey;
    }
}

@john-aws john-aws self-assigned this Apr 10, 2020
@MattBlissett
Copy link

I noticed the same issue with the af-south-1 region. This fix seems to work.

I'll copy the change above, since the formatting is broken. s3- is changed to s3.

    function object2hrefvirt(bucket, key) {
        var enckey = key.split('/').map(function(x) { return encodeURIComponent(x); }).join('/');

        if (AWS.config.region === "us-east-1") {
            return document.location.protocol + '//' + bucket + '.s3.amazonaws.com/' + enckey;
        } else {
            return document.location.protocol + '//' + bucket + '.s3.' + AWS.config.region + '.amazonaws.com/' + enckey;
        }
    }

    function object2hrefpath(bucket, key) {
        var enckey = key.split('/').map(function(x) { return encodeURIComponent(x); }).join('/');

        if (AWS.config.region === "us-east-1") {
            return document.location.protocol + "//s3.amazonaws.com/" + bucket + "/" + enckey;
        } else {
            return document.location.protocol + "//s3.' + AWS.config.region + '.amazonaws.com/" + bucket + "/" + enckey;
        }
    }

I would submit a PR, but I spotted this:

// The following is also a legal form, but we do not support it, so
// you should use s3-eu-central-1 rather than s3.eu-central-1:
// - bucket3.s3.eu-central-1.amazonaws.com

and I don't know enough about AWS URLs to be sure of all the possibilities. s3-eu-central-1 works, but s3-af-south-1 does not.

(The URLs don't seem to be consistent between regions, e.g. https://gbif-open-data-eu-central-1.s3-eu-central-1.amazonaws.com/occurrence/2021-04-13/citation.txt and https://gbif-open-data-eu-central-1.s3.eu-central-1.amazonaws.com/occurrence/2021-04-13/citation.txt both work, with either s3-eu-central-1 or s3.eu-central-1, but https://gbif-open-data-af-south-1.s3-af-south-1.amazonaws.com/occurrence/2021-04-13/citation.txt doesn't work; https://gbif-open-data-af-south-1.s3.af-south-1.amazonaws.com/occurrence/2021-04-13/citation.txt does).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants