Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs for how to use S3 over GridStore? #307

Closed
gateway opened this issue Feb 8, 2016 · 11 comments
Closed

Docs for how to use S3 over GridStore? #307

gateway opened this issue Feb 8, 2016 · 11 comments

Comments

@gateway
Copy link

gateway commented Feb 8, 2016

I see in the depo s3 adaptor but no real docs on how to set this up to work. I know their is a FilesAdapter.js, do I just change these lines.

var GridStoreAdapter = require('./GridStoreAdapter');

var adapter = GridStoreAdapter;

to

var S3Adapter = require('./S3Adapter');

var adapter = S3Adapter;

Then looking at the S3Adaptor code I see various keys that need to be set?

Could we just get a small writeup on this? Also will their be an option on data migration to move files to a s3 bucket instead?

@oclef
Copy link

oclef commented Feb 9, 2016

You can set the FilesAdapter to use S3Adapter when you initialize the ParseServer like this

var api = new ParseServer({
  databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
  cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
  appId: process.env.APP_ID || 'myAppId',
  masterKey: process.env.MASTER_KEY || 'myMasterKey',
  clientKey: process.env.CLIENT_KEY || 'myClientKey',
  restAPIKEY: process.env.RESTAPI_KEY || 'myRestKey',
  fileKey: process.env.FILE_KEY || 'myFileKey',
  filesAdapter: new S3Adapter(
    process.env.AWS_ACCESS_KEY,
    process.env.AWS_SECRET_ACCESS_KEY,
    {bucket: process.env.AWS_BUCKET_NAME, bucketPrefix: "", directAccess: true}
  ),
  pushAdapter: new SNSAdapter(
    process.env.AWS_ACCESS_KEY,
    process.env.AWS_SECRET_ACCESS_KEY,
    {region: "us-east-1"}
  )
});

@gateway
Copy link
Author

gateway commented Feb 9, 2016

@oclef thanks, have you tested it and do pffile saves go to s3 and a reference url goes in the database?

@oclef
Copy link

oclef commented Feb 9, 2016

Yes, I've tested. files goes to s3 and reference goes to mongo

@gateway
Copy link
Author

gateway commented Feb 9, 2016

@oclef thanks, I feel a bit stoopid right now maybe its due to me coding all way and switching between js, php and python but where do I put my aws keys in.. ?

Also I just saw this when trying to deploy the latest parse example..

2016-02-09T01:36:19.232819+00:00 app[web.1]: > parse-server-example@1.0.0 start /app
2016-02-09T01:36:19.232821+00:00 app[web.1]: > node index.js
2016-02-09T01:36:19.232822+00:00 app[web.1]: 
2016-02-09T01:36:20.517814+00:00 app[web.1]: /app/index.js:21
2016-02-09T01:36:20.517819+00:00 app[web.1]:   filesAdapter: new S3Adapter(
2016-02-09T01:36:20.517820+00:00 app[web.1]:                     ^
2016-02-09T01:36:20.517821+00:00 app[web.1]: 
2016-02-09T01:36:20.517823+00:00 app[web.1]:     at Object.<anonymous> (/app/index.js:21:21)
2016-02-09T01:36:20.517822+00:00 app[web.1]: ReferenceError: S3Adapter is not defined
2016-02-09T01:36:20.537757+00:00 app[web.1]: npm ERR! Linux 3.13.0-71-generic
2016-02-09T01:36:20.517823+00:00 app[web.1]:     at Module._compile (module.js:413:34)
2016-02-09T01:36:20.517824+00:00 app[web.1]:     at Object.Module._extensions..js (module.js:422:10)
2016-02-09T01:36:20.517825+00:00 app[web.1]:     at Module.load (module.js:357:32)
2016-02-09T01:36:20.517826+00:00 app[web.1]:     at Function.Module._load (module.js:314:12)
2016-02-09T01:36:20.517826+00:00 app[web.1]:     at Function.Module.runMain (module.js:447:10)
2016-02-09T01:36:20.517827+00:00 app[web.1]:     at startup (node.js:139:18)

@gnz00
Copy link

gnz00 commented Feb 9, 2016

@gateway You need to import the S3Adapter.

var S3Adapter = require('parse-server').S3Adapter;
var ParseServer = require('parse-server').ParseServer;
...
filesAdapter: new S3Adapter({
    /** options **/
});
...

@oclef
Copy link

oclef commented Feb 18, 2016

An adapter I wrote to use AWS SNS as the push server. I've since setup my
own push server so I don't use it anymore. You can find it here

https://github.com/oclef/parseServer

Cheers,
Phong Le

On Thu, Feb 18, 2016 at 3:45 AM, Michael Bina notifications@github.com
wrote:

@oclef https://github.com/oclef What is SNSAdapter and where can I find
it?


Reply to this email directly or view it on GitHub
#307 (comment)
.

Predestination was doomed from the start.

@michaelbina
Copy link

@oclef Looks useful. Did you consider making a pull request? I haven't tried to incorporate ParsePushAdapter which I just looked into, but this looks easier.

@oclef
Copy link

oclef commented Feb 18, 2016

Actually, this is what you will want to use

https://github.com/oclef/parse-server/tree/f2c6cc829927e084fb0a695c30ab701f1c923860

On Thu, Feb 18, 2016 at 3:45 AM, Michael Bina notifications@github.com
wrote:

@oclef https://github.com/oclef What is SNSAdapter and where can I find
it?


Reply to this email directly or view it on GitHub
#307 (comment)
.

Predestination was doomed from the start.

@michaelbina
Copy link

Looks like it was forked a bit behind 2.0.8 so it's gonna take some merging.

@oclef
Copy link

oclef commented Feb 18, 2016

It worked, but it doesn't really conform with the architecture. TBH, it's better to just setup your own push server using the latest release.

@gfosco
Copy link
Contributor

gfosco commented Feb 20, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants