You will need to create an S3 bucket with the following CORS configuration:
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>PUT</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>HEAD</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
Enter this by clicking on the bucket name, then Properties -> Permissions -> Edit CORS Configuration.
You must also create a set of security keys and put them in the appropriate place in the settings file.
- AWSACL
- Amazon Web Services Access Control List for sent files
- AWSAccessKeyId
- Your AWS access key
- AWSBucketName
- The name of your S3 bucket
- AWSRegion
- The x-xx-x string representing your bucket region, if not us-east-1
- AWSSecretAccessKey
- Your AWS secret key
- debug
- If set to true, output debugging messages, otherwise do not
- public.debug
- Same as above but for client-side messages
- public.httpTimeout
- Max amount of time to wait for return for file transfer from client-side URL to finish
- Catapult.mimeTypes
- List of MIME type codes to accept for client-side URL transfers
- Catapult.maxMB
- Max file size for client-side URL transfers
- Catapult.saveSourceLinksToDb
- Keep log of source links, feature not yet available
- Catapult.saveTargetLinksToDb
- Keep log of source links for s3URLs helper, currently always true
Relies on the following packages:
- aldeed:http
- blaze-html-templates
- check
- edgee:slingshot
- ejson
- jquery
- lepozepo:s3
- logging
- meteor-base
- mongo
- npm.http
- random
- reload
- spacebars
- tracker
- underscore
Provides the following templates:
- s3Link
- Simply provides a link tag named after the URL
- s3URLs
- A clickable list of uploaded files wrapped in a div with 's3URLs' class
- s3UploadURLForm
- Form with id 's3UploadURL' and a single text input
- s3UploadFileForm
- Form with id 's3UploadFileForm' and a single file input
Insert {{> s3URLs}}, {{> s3UploadURLForm}} or {{> s3UploadFileForm}} anywhere inside one of your other application templates.
- getFileFromEvent
- Returns the file passed to the file input.
- getFileFromURL
- Returns the file retrieved from a URL to the client, unused
- insertURL
- Inserts a link into the URL collection
- isAmazonURL
- Returns true if the URL contains amazonaws.com
- isHTTPObject
- Returns true if passed parameters looks like an HTTP.get() result
- isTemplateInstance
- Returns true if the parameter is an instance of Blaze.Template
- isValidURL
- Returns true if a passed string looks like a URL
- log
- Processes debugging messages
- pressedEnter
- Returns true if passed a keypress event & enter was pressed
- postProcessAmazon
- Ensures all went well with xfer to Amazon then calls the URL insertion
- postProcessInsert
- Just logs success or failure of call to s3InsertURL
- sanitizeFileName
- Turns a string into a URL safe string
- sendFile
- Validates a file passed to file input and sends it to sendToAmazon
- sendToAmazon
- Actually sends a file to Amazon
- sendURL
- Validates a URL and sends it to Meteor.call('s3GetURL', url);
- urlExists
- Checks the database for a file from the passed URL
If the MDG Browser Policy package is detected, we will add *.s3.amazonaws.com to the allowOriginForAll policy. Probably won't work without it. :)
The s3URLs collection is used to store a list of uploaded files. The allow/deny model prevents all CRUD operations attempted directly from a client, only server side manipulations are allowed.
The URLs collection is published to clients and subscribed to when the 's3URLs' template is created. All allow rules return true, as do all the deny rules, thereby only allowing db manipulation from server-side code.
- s3GetURL
- Downloads a file from a given URL and sends it to Amazon, with optional name and prefix parameters.
- s3InsertURL
- Safely inserts a validated URL into the URLs collection
- s3URLs
- The template is provided a 'urls' helper, a simple list of files
- s3UploadFileForm
- When the user selects or drops a file on the input area, the file will be send to S3
- s3UploadURLForm
- If the user presses enter in the input field or clicks submit, the URL will be tested for validity and then streamed to S3
- Added optional name and prefix parameters to sendURL and s3GetURL