Last active
September 4, 2020 14:44
-
-
Save PCreations/9fadcad021117d54bf609b97fc85f887 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, 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