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

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more