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.
Install using Meteorite. When in a Meteor app directory, enter:
$ mrt add cfs-s3
- 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. - 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 theendpoint
option, using the value from that same table. - In AWS IAM, create a new user. Copy the generated key and secret and paste into the S3 store options in your project.
- Select your newly created user. In the bottom area, select Permissions > Attach User Policy.
- Select Custom Policy.
- 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.
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.
- 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.