Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for ACL, Content-Type, Max File Size and allowed Content-Types #47

Merged

Conversation

seriousben
Copy link
Contributor

Adds support for:

  • ACL
  • Content-Type
  • Max File Size (defaults to 10 MB)
  • Allowed Content-Types

Notes:

  • Max File Size will not cause the whole file to be downloaded, but will not cleanup after itself for now. We should discuss the best way to do this.

Examples:

var dsImage = loopback.createDataSource({
  connector: require('loopback-component-storage'),
  provider: 'filesystem',
  root: path.join(__dirname, 'images'),

  getFilename: function(fileInfo) {
    return 'image-' + fileInfo.name;
  },
  acl: 'public-read',
  allowedContentTypes: ['image/png', 'image/jpeg'],
  maxFileSize: 5 * 1024 * 1024
});

or using the handler directly:

handler.upload(req, res, {
  container: 'images',
  maxFileSize: 10 * 1024 * 1024,
  allowedContentTypes: ['image/png', 'image/jpeg'],
  acl: 'public-read',
  getFilename: function(fileInfo) {
    return 'image-' + fileInfo.name;
  }
}, function(err, result) {
});

@seriousben
Copy link
Contributor Author

Fixes #45 #44 and #33

raymondfeng added a commit that referenced this pull request Feb 10, 2015
Adding support for ACL, Content-Type, Max File Size and allowed Content-Types
@raymondfeng raymondfeng merged commit 468b246 into strongloop:master Feb 10, 2015
@raymondfeng
Copy link
Member

@seriousben Thank you for the contribution!

@seriousben seriousben deleted the feature/more-configurations branch February 10, 2015 16:44
@pbrain19
Copy link

how do we do this using JSON only?

@mvllg
Copy link

mvllg commented Aug 5, 2017

Guys sorry for my stuppid ask but where i put that code on my simple api with loopback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants