Skip to content

Commit

Permalink
Merge pull request #9 from CulturalMe/#3-unlimited-file-size
Browse files Browse the repository at this point in the history
#3 Max size 0 or null is now respected
  • Loading branch information
gsuess committed Dec 1, 2014
2 parents 2e0f05e + 343de4e commit 827ebec
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ if required.

## Security

The secret key never leaves the meteor app server. Nobody will be able to upload
The secret key never leaves the meteor app server. Nobody will be able to upload
anything to your buckets outside of your meteor app.

Instead of using secret access keys, Slingshot uses a policy document that is
Expand All @@ -204,8 +204,8 @@ the directive. By default a signed policy expires after 5 minutes.

`authorize`: Function (required) - Function to determines if upload is allowed.

`maxSize`: Number (required) - Maximum file-size (in bytes). Use null for
unlimited.
`maxSize`: Number (required) - Maximum file-size (in bytes). Use `null` or `0`
for unlimited.

`allowedFileTypes` RegExp, String or Array (required) - Allowed MIME types. Use
null for any file type.
Expand Down
2 changes: 1 addition & 1 deletion lib/directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ Slingshot.Directive = function (service, directive) {

check(directive, _.defaults({
authorize: Function,
maxSize: Number,
maxSize: Match.OneOf(Number, null),
allowedFileTypes: matchAllowedFileTypes,
cacheControl: Match.Optional(String),
contentDisposition: Match.Optional(Match.OneOf(String, null))
Expand Down
2 changes: 1 addition & 1 deletion services/aws-s3.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Slingshot.S3Storage = {
var url = Npm.require("url"),
policy = new Slingshot.StoragePolicy()
.expireIn(directive.expire)
.contentLength(0, Math.min(file.size, directive.maxSize)),
.contentLength(0, Math.min(file.size, directive.maxSize || Infinity)),

payload = {
key: _.isFunction(directive.key) ?
Expand Down
2 changes: 1 addition & 1 deletion services/google-cloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Slingshot.GoogleCloud = {
var url = Npm.require("url"),
policy = new Slingshot.StoragePolicy()
.expireIn(directive.expire)
.contentLength(0, Math.min(file.size, directive.maxSize)),
.contentLength(0, Math.min(file.size, directive.maxSize || Infinity)),
payload = {
key: _.isFunction(directive.key) ?
directive.key.call(method, file, meta) : directive.key,
Expand Down

0 comments on commit 827ebec

Please sign in to comment.