I'm trying to get signed URL to put a file from aws-sdk with Node.js. When I use the address from the SDK, I will get 301 PermanentRedirect.
<Error>
<script/>
<Code>PermanentRedirect</Code>
<Message>
The bucket you are attempting to access must be addressed using the
specified endpoint. Please send all future requests to this endpoint.
</Message>
<Bucket>XXX.COM</Bucket>
<Endpoint>XXX.COM.s3.amazonaws.com</Endpoint>
<RequestId>A82721F2A44XXXX</RequestId><HostId>HPgWeSUk2cKu3AbijEu9+S41bHh7dUxSiwOEEVrS08dsrpJ3AvMP5V2iXXXXXX
</HostId>
</Error>
I think I have no authentication problems since I could access the other API before calling getSignedURL API. I have no idea why I could get this error message. This is the code I using for getting signed URL.
public static getSignedURL(path: string, op: string): Promise<string> {
return new Promise<string>((resolve, reject) => {
s3.getSignedUrl(op, {
Bucket: "XXX.COM",
Key: path,
Expires: 60 * 60 * 24 * 365 * 10,
ContentType: "text/javascript",
ACL: 'public-read'
}, (err, url) => {
if (err) {
reject(err);
} else {
resolve(url);
}
})
});
console.log(await getSignedURL(`XXX/${id}/${libName}.js`, "putObject"));
Is there any problems on my code?