|
| 1 | +# parse-server-s3-adapter |
| 2 | +parse-server adapter for AWS S3 |
| 3 | + |
| 4 | +# installation |
| 5 | + |
| 6 | +`npm install --save parse-server-s3-adapter` |
| 7 | + |
| 8 | +# usage with parse-server |
| 9 | + |
| 10 | +### using a config file |
| 11 | + |
| 12 | +``` |
| 13 | +{ |
| 14 | + "appId": 'my_app_id', |
| 15 | + "masterKey": 'my_master_key', |
| 16 | + // other options |
| 17 | + "filesAdapter": { |
| 18 | + "module": "parse-server-s3-adapter", |
| 19 | + "options": { |
| 20 | + "accessKey": "accessKey", |
| 21 | + "secretKey": "secretKey", |
| 22 | + "bucket": "my_bucket", |
| 23 | + // optional: |
| 24 | + "region": 'US_EAST_2', // default value |
| 25 | + "bucketPrefix": '', // default value |
| 26 | + "directAccess": false // default value |
| 27 | + } |
| 28 | + } |
| 29 | +} |
| 30 | +``` |
| 31 | + |
| 32 | +### using environment variables |
| 33 | + |
| 34 | +Set your environment variables: |
| 35 | + |
| 36 | +``` |
| 37 | +S3_ACCESS_KEY=accessKey |
| 38 | +S3_SECRET_KEY=secretKey |
| 39 | +S3_BUCKET=bucketName |
| 40 | +``` |
| 41 | + |
| 42 | +And update your config / options |
| 43 | + |
| 44 | +``` |
| 45 | +{ |
| 46 | + "appId": 'my_app_id', |
| 47 | + "masterKey": 'my_master_key', |
| 48 | + // other options |
| 49 | + "filesAdapter": "parse-server-s3-adapter" |
| 50 | +} |
| 51 | +``` |
| 52 | + |
| 53 | + |
| 54 | +### passing as an instance |
| 55 | + |
| 56 | +``` |
| 57 | +var S3Adapter = require('parse-server-s3-adapter'); |
| 58 | +
|
| 59 | +var s3Adapter = new S3Adapter('accessKey', |
| 60 | + 'secretKey', |
| 61 | + 'bucket' , { |
| 62 | + region: 'US_EAST_2' |
| 63 | + bucketPrefix: '', |
| 64 | + directAccess: false |
| 65 | + }); |
| 66 | +
|
| 67 | +var api = new ParseServer({ |
| 68 | + appId: 'my_app', |
| 69 | + masterKey: 'master_key', |
| 70 | + filesAdapter: s3adapter |
| 71 | +}) |
| 72 | +``` |
| 73 | + |
| 74 | +or with an options hash |
| 75 | + |
| 76 | +``` |
| 77 | +var S3Adapter = require('parse-server-s3-adapter'); |
| 78 | +
|
| 79 | +var s3Options = { |
| 80 | + "accessKey": "accessKey", |
| 81 | + "secretKey": "secretKey", |
| 82 | + "bucket": "my_bucket", |
| 83 | + // optional: |
| 84 | + "region": 'US_EAST_2', // default value |
| 85 | + "bucketPrefix": '', // default value |
| 86 | + "directAccess": false // default value |
| 87 | +} |
| 88 | +
|
| 89 | +var s3Adapter = new S3Adapter(s3Options); |
| 90 | +
|
| 91 | +var api = new ParseServer({ |
| 92 | + appId: 'my_app', |
| 93 | + masterKey: 'master_key', |
| 94 | + filesAdapter: s3Adapter |
| 95 | +}) |
| 96 | +``` |
| 97 | + |
| 98 | + |
0 commit comments