Giter Club home page Giter Club logo

parse-server-s3-adapter's Introduction

parse-server-s3-adapter

codecov.io Build Status

parse-server adapter for AWS S3

installation

npm install --save parse-server-s3-adapter

aws credentials

Although it is not recommended, AWS credentials can be explicitly configured through an options object, constructor string arguments or environment variables (see below). This option is provided for backward compatibility.

The preferred method is to use the default AWS credentials pattern. If no AWS credentials are explicitly configured, the AWS SDK will look for credentials in the standard locations used by all AWS SDKs and the AWS CLI. More info can be found in the docs. For more information on AWS best practices, see IAM Best Practices User Guide.

usage with parse-server

using a config file

{
  "appId": 'my_app_id',
  "masterKey": 'my_master_key',
  // other options
  "filesAdapter": {
    "module": "parse-server-s3-adapter",
    "options": {
      "bucket": "my_bucket",
      // optional:
      "accessKey": "accessKey",
      "secretKey": "secretKey",
      "region": 'us-east-1', // default value
      "bucketPrefix": '', // default value
      "directAccess": false, // default value
      "baseUrl": null, // default value
      "baseUrlDirect": false, // default value
      "signatureVersion": 'v4', // default value
      "globalCacheControl": null // default value. Or 'public, max-age=86400' for 24 hrs Cache-Control
    }
  }
}

using environment variables

Set your environment variables:

S3_BUCKET=bucketName

the following optional configurations can be set by environment variables too:

S3_ACCESS_KEY=accessKey
S3_SECRET_KEY=secretKey
S3_SIGNATURE_VERSION=v4

And update your config / options

{
  "appId": 'my_app_id',
  "masterKey": 'my_master_key',
  // other options
  "filesAdapter": "parse-server-s3-adapter"
}

passing as an instance

var S3Adapter = require('parse-server-s3-adapter');

var s3Adapter = new S3Adapter('accessKey',
                  'secretKey', bucket, {
                    region: 'us-east-1'
                    bucketPrefix: '',
                    directAccess: false,
                    baseUrl: 'http://images.example.com',
                    signatureVersion: 'v4',
                    globalCacheControl: 'public, max-age=86400'  // 24 hrs Cache-Control.
                  });

var api = new ParseServer({
	appId: 'my_app',
	masterKey: 'master_key',
	filesAdapter: s3adapter
})

Note: there are a few ways you can pass arguments:

S3Adapter("bucket")
S3Adapter("bucket", options)
S3Adapter("key", "secret", "bucket")
S3Adapter("key", "secret", "bucket", options)
S3Adapter(options) // where options must contain bucket.
S3Adapter(options, s3overrides)

If you use the last form, s3overrides are the parameters passed to AWS.S3.

In this form if you set s3overrides.params, you must set at least s3overrides.params.Bucket

or with an options hash

var S3Adapter = require('parse-server-s3-adapter');

var s3Options = {
  "bucket": "my_bucket",
  // optional:
  "accessKey": null, // default value
  "secretKey": null, // default value
  "region": 'us-east-1', // default value
  "bucketPrefix": '', // default value
  "directAccess": false, // default value
  "baseUrl": null // default value
  "signatureVersion": 'v4', // default value
  "globalCacheControl": null // default value. Or 'public, max-age=86400' for 24 hrs Cache-Control
}

var s3Adapter = new S3Adapter(s3Options);

var api = new ParseServer({
  appId: 'my_app',
  masterKey: 'master_key',
  filesAdapter: s3Adapter
})

parse-server-s3-adapter's People

Contributors

flovilmart avatar davimacedo avatar jsuresh avatar joeyslack avatar kbog avatar davidruisinger avatar ststroppel avatar dsix-work avatar

Watchers

mntz avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.