Skip to content

Instantly share code, notes, and snippets.

@PCreations
Last active September 4, 2020 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PCreations/fe2289e4e9e70e1a4e790d705056a72a to your computer and use it in GitHub Desktop.
Save PCreations/fe2289e4e9e70e1a4e790d705056a72a to your computer and use it in GitHub Desktop.
import aws from "aws-sdk";
aws.config.update({
accessKeyId: process.env.ACCESS_KEY_ID,
secretAccessKey: process.env.SECRET_ACCESS_KEY,
region: process.env.REGION,
});
export const createS3xmlUploader = ({ bucketName }) => {
const s3 = new aws.S3();
let lastPutObject;
return {
upload({ domain, xmlString }) {
const objectToPut = {
Bucket: bucketName,
Key: `${domain}/sitemap.xml`,
Body: xmlString,
ContentType: "application/xml",
};
return s3
.putObject(objectToPut)
.promise()
.then(() => {
lastPutObject = objectToPut;
});
},
getLastPutObject() {
return lastPutObject;
},
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment