Uploads things to S3 on the client using signed S3 policies created on the server
Requires a policy form generated by meteor-s3-policy-generator on the server. So you can do something like this:
# server.coffee
policyGenerator = new S3PolicyGenerator(
awsAccessKeyId: Meteor.settings.AWS_ACCESS_KEY_ID
awsSecretAccessKey: Meteor.settings.AWS_SECRET_ACCESS_KEY
awsBucket: Meteor.settings.AWS_BUCKET_NAME
awsBaseUrl: Meteor.settings.AWS_S3_BASE_URL
awsRegion: Meteor.settings.AWS_REGION
)
Meteor.methods ->
getS3Policy: ->
options =
acl: 'public-read'
maxBytes: 1024 * 1024 * 5
contentType: 'application/json'
policyGenerator.generate(path, options)
# client.coffee
uploader = new S3ClientsideUploader()
Meteor.call 'getS3Policy', (err, policy) ->
uploader.upload myData, policy, (xhr) ->
if xhr.status == 204
alert 'OK'