Git Product home page Git Product logo

meteor-cfs-s3's Introduction

cfs-s3

NOTE: This package is under active development right now (2014-2-20). It has bugs and the API may continue to change. Please help test it and fix bugs, but don't use in production yet.

A Meteor package that adds Amazon S3 storage for CollectionFS.

Installation

Install using Meteorite. When in a Meteor app directory, enter:

$ mrt add cfs-s3

S3 Setup

  1. In AWS S3, create a new bucket for your CFS store. Enter the name of the bucket for the bucket option in your S3 store options.
  2. Select the bucket, and then select Properties. Note the region, and enter the correct region in your S3 store options in your project. S3 displays the region name rather than the actual region, so you need to check out this table and use the corresponding value from the "Region" column for your store region value. Alternatively, you can specify the endpoint option, using the value from that same table.
  3. In AWS IAM, create a new user. Copy the generated key and secret and paste into the S3 store options in your project.
  4. Select your newly created user. In the bottom area, select Permissions > Attach User Policy.
  5. Select Custom Policy.
  6. To create the custom policy, give it any name you want, and then copy and paste the example policy below. Replace "mybucketname" with your actual bucket name.
{
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "s3:ListAllMyBuckets",
        "s3:ListBucket"
      ],
      "Resource": "arn:aws:s3:::*"
    },
    {
      "Action": [
        "s3:PutObject",
        "s3:PutObjectAcl",
        "s3:GetObject",
        "s3:GetObjectAcl",
        "s3:DeleteObject",
        "s3:DeleteObjectAcl"
      ],
      "Effect": "Allow",
      "Resource": [
        "arn:aws:s3:::mybucketname/*"
      ]
    }
  ]
}

You may have to wait for an unknown number of minutes for the new security to take effect.

Usage

Perform the steps in the "S3 Setup" section, putting the necessary information into your S3Store options, like so:

var imageStore = new FS.Store.S3("images", {
  region: "my-s3-region", //required, or use endpoint option
  accessKeyId: "account or IAM key", //required if environment variables are not set
  secretAccessKey: "account or IAM secret", //required if environment variables are not set
  bucket: "mybucket", //required
  ACL: myValue //optional, default is 'private'
  beforeSave: myBeforeSaveFunction, //optional
  maxTries: 1 //optional, default 5
});

Images = new FS.Collection("images", {
  stores: [imageStore]
});

Refer to the CollectionFS package documentation for more information.

Notes

  • An S3 store does not support the sync option.
  • Be sure to define your store in a server file that is not shipped to the client since it contains credentials. Wrapping in Meteor.isServer is not secure. For best security, you can omit the key and secret options and instead set your credentials in environment variables.

API

For Users

For Contributors

meteor-cfs-s3's People

Contributors

aldeed avatar

Watchers

 avatar  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.