public getUrl(location: string): string {
const {
endpoint: configEndpoint,
bucket,
forcePathStyle,
region,
} = this.$config;
const awsHost = region ? `s3.${region}.amazonaws.com` : "s3.amazonaws.com";
let endpoint = (configEndpoint as string) || `https:${awsHost}`;
endpoint = endpoint.replace(bucket, "");
const { href, protocol, host } = new URL(endpoint);
if (href.includes("amazonaws.com")) {
if (!forcePathStyle) {
return `${protocol}//${bucket}.${host}/${location}`;
}
}
return `${protocol}//${host}/${bucket}/${location}`;
}
Created
August 1, 2023 08:29
-
-
Save axmad386/bd68e934efbadcde4984050f7ce1350c to your computer and use it in GitHub Desktop.
Get S3 public url without s3 sdk
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment