Published
Edited
Dec 25, 2020
3 forks
6 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
AWS.config.credentials = new AWS.Credentials(localStorage["accessKeyId"], localStorage["secretAccessKey"])
Insert cell
Insert cell
AWS.config.region = "us-east-1"
Insert cell
Insert cell
auth_AWS = {
AWS.config.credentials;
AWS.config.region;
return AWS;
}
Insert cell
Insert cell
s3 = new auth_AWS.S3({apiVersion: '2006-03-01'});
Insert cell
Insert cell
Insert cell
bucketParams = ({
Bucket : bucketName,
Delimiter : '/',
Prefix : folderName
});
Insert cell
Insert cell
Insert cell
objectParams = ({
Bucket : bucketName,
Key : objectName
});
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
available_objects = s3.listObjects(bucketParams).promise().then((object) => object.Contents);
Insert cell
available_objects_full_path = listS3Objects()
Insert cell
listS3Objects = () => {
let s3 = new auth_AWS.S3();
var bucketParams = {
Bucket : bucketName,
};
return s3.listObjects(bucketParams).promise().then((json) => json.Contents);
}
Insert cell
Insert cell
Insert cell
Insert cell
loaded_S3_object = s3.getObject(objectParams).promise()
Insert cell
formatted_S3_object = JSON.parse(loaded_S3_object.Body.toString('utf-8'))
Insert cell
viewof key = html`<input type="text" id="key" name="key" placeholder="key" value=${formatted_S3_object[0].key}>`
Insert cell
viewof sort = html`<input type="text" id="sort" name="sort" placeholder="sort" value=${formatted_S3_object[0].sort}>`
Insert cell
viewof comment = html`<input type="text" id="comment" name="comment" placeholder="comment" value=${formatted_S3_object[0].comment}>`
Insert cell
changed_object = [
{
"key":key,
"sort":sort,
"comment":comment,
}
]
Insert cell
Insert cell
changed_object_formatted = JSON.stringify(changed_object)
Insert cell
write_to_s3 = s3.putObject({
Body: changed_object_formatted,
Bucket: bucketName,
Key: objectName
}).promise()
Insert cell
Insert cell
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more