parse-server-oss-adapter
v1.0.0
Published
aliyun OSS adapter for parse-server
Downloads
15
Readme
parse-server-oss-adapter
parse-server adapter for aliyun OSS
installation
npm install --save parse-server-oss-adapter
usage with parse-server
using a config file
{
"appId": 'my_app_id',
"masterKey": 'my_master_key',
// other options
"filesAdapter": {
"module": "parse-server-oss-adapter",
"options": {
"accessKey": "accessKey",
"secretKey": "secretKey",
"bucket": "my_bucket",
// optional:
"region": 'oss-cn-hangzhou', // default value
"bucketPrefix": '', // default value
"directAccess": false, // default value
"baseUrl": null, // default value
"baseUrlDirect": false // default value
}
}
}
using environment variables
Set your environment variables:
OOS_ACCESS_KEY=accessKey
OOS_SECRET_KEY=secretKey
OOS_BUCKET=bucketName
And update your config / options
{
"appId": 'my_app_id',
"masterKey": 'my_master_key',
// other options
"filesAdapter": "parse-server-oss-adapter"
}
passing as an instance
var OSSAdapter = require('parse-server-oss-adapter');
var ossAdapter = new OSSAdapter('accessKey',
'secretKey',
'bucket' , {
region: 'oss-cn-hangzhou'
bucketPrefix: '',
directAccess: false,
baseUrl: 'http://images.example.com'
});
var api = new ParseServer({
appId: 'my_app',
masterKey: 'master_key',
filesAdapter: ossAdapter
})
or with an options hash
var OSSAdapter = require('parse-server-oss-adapter');
var ossOptions = {
"accessKey": "accessKey",
"secretKey": "secretKey",
"bucket": "my_bucket",
// optional:
"region": 'oss-cn-hangzhou', // default value
"bucketPrefix": '', // default value
"directAccess": false, // default value
"baseUrl": null // default value
}
var ossAdapter = new OSSAdapter(ossOptions);
var api = new ParseServer({
appId: 'my_app',
masterKey: 'master_key',
filesAdapter: ossAdapter
})