Last active
September 4, 2020 14:40
-
-
Save PCreations/fe2289e4e9e70e1a4e790d705056a72a 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 }) => { | |
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