Last active
August 20, 2020 17:34
-
-
Save simonjcarr/037404bcd18e35e33fed6a6f62ddcf12 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| var AWS = require('aws-sdk') | |
| var s3 = new AWS.S3({ | |
| accessKeyId: 'admin', | |
| secretAccessKey: 'password', | |
| endpoint: 'http://localhost:9001', | |
| s3ForcePathStyle: true, | |
| signatureVersion: 'v4' | |
| }) | |
| s3.createBucket({ Bucket: "awstest" }, (err, data) => { | |
| if (err) | |
| console.log("Error: ", err) | |
| else | |
| console.log("Success: ", data.Location) | |
| }) | |
| var params = { Bucket: 'awstest', Key: 'testobject', Body: 'Hello from MinIO!' }; | |
| s3.putObject(params, (err, data) => { | |
| if (err) { | |
| console.log(err) | |
| } else { | |
| console.log("Successfully uploaded data to testbucket/testobject") | |
| } | |
| }) | |
| var params = { Bucket: 'awstest', Key: 'testobject' } | |
| var file = require('fs').createWriteStream('./test_from_minio.txt') | |
| s3.getObject(params) | |
| .on('httpData', (chunk) => { file.write(chunk) }) | |
| .on('httpDone', () => { file.end() }) | |
| .send() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment