Hi can you help me find what I'm missing? Using "version": "0.8.2". I want to use gun as a custom service in Feathers. Using postman to hit endpoints and getting 200 as expected with this local url "localhost:3030/gun?imthemiddle=notevenclose". This writes to the local data.json file but neither are hitting the S3 bucket.
Thread about including Gun as a feathers adaptor. #https://github.com/feathersjs/feathers/issues/291
I've created a policy on the bucket, as such:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": "*",
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::sxan",
"arn:aws:s3:::sxan/*"
]
}
]
}
Here's the code inside the get request from the examples:
`const server = require('http').createServer(function(req, res){
if(Gun.serve(req, res)){ return; } // filters gun requests!
require('fs').createReadStream(require('path').join(__dirname, req.url)).on('error',function(){ // static files!
res.writeHead(200, {'Content-Type': 'text/html'});
res.end(require('fs')
.readFileSync(require('path')
.join(__dirname, 'index.html') // or default to index
));
}).pipe(res); // stream
});
const gun = Gun({
file: 'data.json',
web: server,
s3: {
key: 'XXXXX', // AWS Access Key
secret: 'XXXXX', // AWS Secret Token
bucket: 'sxan' // The bucket you want to save into
}
});
gun.get('narc').put(params);
gun.get('narc').on(function(data, key){
logger.info('update:', data);
});
gun.on('out', {get: {'#': {'*': ''}}});
const port = process.env.OPENSHIFT_NODEJS_PORT || process.env.VCAP_APP_PORT || process.env.PORT || process.argv[2] || 8080;
server.listen(port);`
Thanks for creating this tech and for any attention to help me understand.
@irthos welcome :)!!!
Just out of the gate, v0.8.2+ should log a big fat warning message that the S3 adapter is broken in the most recent release: https://github.com/amark/gun/blob/master/lib/s3.js#L13 . I apologize for that, I am actively working on fixing that but it is taking longer and my life has been insanely busy lately.
Great to hear about the Feathers adapter! Just a quick note: you probably will not want to create a new gun instance on every request, it would be better to create it once at the top of the file, then re-use it each time in the request.
Your S3 policy looks correct enough compared to https://github.com/amark/gun/wiki/Using-Amazon-S3-for-Storage .
So very likely this is just the big warning that S3 is broken in the current release. We'll be working on getting this fixed. Sorry for the delay! :)
Right on, thanks for the update. I keep posted!
Any ETA on this fix?
@yieme sorry I got delayed, I moved my entire family across the continent and had a backlog of work. To make things worse, I'm headed out to Sweden in a few days and need to polish my tech talk on it.
However, getting this working/fixed is my current "main" programming focus (not necessarily getting S3 itself working, but the new Radix Storage Engine and the internal updates/fixes that the S3 adapter depends upon, it should work after that). I wish I could give an ETA :(...
To help speed me up, what projects are you working on that are needing this? Would love to learn and hear!
In what version does the S3 adapter work?
@Ronsku I believe v0.7.9 and below it should work. Again, sorry for the delays, life has been insanely stressful with personal/business/other stuff.
This is being worked on though!
@irthos @yieme @Ronsku this is now fixed :) in v0.9.1 (available on master branch in GitHub, and should be NPM published sometime this next week).
As long as you provide the standard environment configs such as AWS_S3_BUCKET, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and set Gun({localStorage: false}) on the server, the S3 Radix Storage Engine (RSE) should automatically run.
The demo server is now up to date, and running it, which is on Heroku. If you are using Heroku, you go to your dashboard, choose the app, go to settings, click to reveal config environments, then edit them with the above keys, and set the values to be the bucket/secret/access IDs you have with AWS. Note: Check the wiki for the article "S3 template" for more info.
Closing!
of course, hit me up with any other Qs if you need them. Warning: there is a very rare edge-case bug with RSE, but I'm trying to encourage people to run/alpha-test it anyways.
Most helpful comment
@irthos @yieme @Ronsku this is now fixed :) in
v0.9.1(available on master branch in GitHub, and should be NPM published sometime this next week).As long as you provide the standard environment configs such as
AWS_S3_BUCKET,AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY, and setGun({localStorage: false})on the server, the S3 Radix Storage Engine (RSE) should automatically run.The demo server is now up to date, and running it, which is on Heroku. If you are using Heroku, you go to your dashboard, choose the app, go to settings, click to reveal config environments, then edit them with the above keys, and set the values to be the bucket/secret/access IDs you have with AWS. Note: Check the wiki for the article "S3 template" for more info.
Closing!