parse-server-example icon indicating copy to clipboard operation
parse-server-example copied to clipboard

Set S3 as File adapter, but uploaded file still goes to MongDB

Open wandonye opened this issue 10 years ago • 9 comments

Seems I'm not alone: http://stackoverflow.com/questions/35824461/store-parse-files-to-amazon-s3-using-ios-swift-xcode

This is the tutorial that I followed: https://github.com/ParsePlatform/parse-server/wiki/Configuring-File-Adapters#configuring-s3adapter

Here is my configuration: screen shot 2016-03-23 at 1 36 21 am

wandonye avatar Mar 23 '16 06:03 wandonye

@wandonye If you're using Node.js/Express you will have to write it directly in thee index.js file instead of the elastic beanstalk options. Also make sure you versions are up to date. once changes are made you have to restart app servers

jdzorz avatar Mar 23 '16 17:03 jdzorz

@wandonye were you able to solve this ?

poojanjhaveri avatar Mar 23 '16 18:03 poojanjhaveri

@jdzorz I'm not using Express, or I don't know what it is. I used the "deploy to AWS" button on one of the wiki page. Can I assume that is an up-to-date version?

wandonye avatar Mar 23 '16 18:03 wandonye

@poojanjhaveri Not yet...

wandonye avatar Mar 23 '16 18:03 wandonye

The deploy to aws button is using express. If you launhed it recently that yes it should be the most up to date version. So what you have to do is edit the index.js file and add this:

var S3Adapter = require('parse-server').S3Adapter;

var api = new ParseServer({ databaseURI: databaseUri || 'mongodb://localhost:27017/dev', appId: process.env.APP_ID || 'APPLICATION_ID', masterKey: process.env.MASTER_KEY || 'MASTER_KEY', ... filesAdapter: new S3Adapter( "S3_ACCESS_KEY", "S3_SECRET_KEY", "S3_BUCKET", {directAccess: true} ), ...

then restart your app

jdzorz avatar Mar 23 '16 18:03 jdzorz

Thanks for pointing out the right direction. I unzipped "parse-server-example.zip", added the codes into index.js, zipped the folder, uploaded and deployed it. But now I get the following error:

The configuration file __MACOSX/parse-server-example-3/.ebextensions/._app.config in application version parse-server-s3 contains invalid YAML or JSON. YAML exception: unacceptable character '' (0x0) special characters are not allowed in "", position 0, JSON exception: Unexpected character () at position 0.. Update the configuration file.

wandonye avatar Mar 23 '16 22:03 wandonye

I think I got it. Mac creates some secret folder itself...

wandonye avatar Mar 23 '16 22:03 wandonye

Still running into all kinds of problems. I removed _MACOSX folders and deployed, got 520 Error. I thought it might be not right to compress the folder "parse-server-example-3", so I went into the folder and compressed everything inside. Now when deploy it, I get:

[Instance: i-0182be514af666540] Command failed on instance. Return code: 1 Output: (TRUNCATED)...yfile('%s/npm-debug.log' % app_path, '/var/log/nodejs/npm-debug.log') File "/usr/lib64/python2.7/shutil.py", line 82, in copyfile with open(src, 'rb') as fsrc: IOError: [Errno 2] No such file or directory: '/tmp/deployment/application/npm-debug.log'. Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/50npm.sh failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.

Here is the changed index.js: screen shot 2016-03-23 at 7 15 24 pm I apparently underestimated the complexity of this task.

wandonye avatar Mar 23 '16 23:03 wandonye

Can you add a comma after the {directAccess: true, region: 'us-west-2'} ),
});

looks like thats whats missing.

jdzorz avatar Mar 24 '16 13:03 jdzorz