Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a365301

Browse files
authoredJul 5, 2020
Add files via upload
1 parent 1ac2433 commit a365301

File tree

4 files changed

+148
-0
lines changed

4 files changed

+148
-0
lines changed
 

‎functions/save.js

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
const AWS = require("aws-sdk");
2+
3+
exports.handler = function(event, context, callback) {
4+
// const { identity, user } = context.clientContext;
5+
6+
// Configure client for use with Spaces
7+
const spacesEndpoint = new AWS.Endpoint(S3_ENDPOINT);
8+
const s3 = new AWS.S3({
9+
endpoint: spacesEndpoint,
10+
accessKeyId: process.env.S3_KEY,
11+
secretAccessKey: process.env.S3_SECRET,
12+
});
13+
14+
// Add a file to a Space
15+
var params = {
16+
Body: "The contents of the file",
17+
Bucket: "netlify-spaces",
18+
Key: "data.json",
19+
};
20+
21+
s3.putObject(params, function(err, data) {
22+
if (err) console.log(err, err.stack);
23+
else console.log(data);
24+
});
25+
26+
callback(null, {
27+
statusCode: 200,
28+
body: JSON.stringify({ foo: "bar" }),
29+
});
30+
};

‎netlify.toml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[build]
2+
functions = "functions/"

‎package-lock.json

+102
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "netlify-spaces",
3+
"version": "1.0.0",
4+
"description": "Uses Netlify for auth, and DO Spaces for storage",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"author": "",
10+
"license": "ISC",
11+
"dependencies": {
12+
"aws-sdk": "^2.709.0"
13+
}
14+
}

0 commit comments

Comments
 (0)
Please sign in to comment.