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

Pass arguments createDirective #71

Closed
madshargreave opened this issue Feb 20, 2015 · 4 comments
Closed

Pass arguments createDirective #71

madshargreave opened this issue Feb 20, 2015 · 4 comments
Labels

Comments

@madshargreave
Copy link

Is it possible to pass arguments to the createDirective function, so that one can use such when creating the key/filename?

@gsuess
Copy link
Contributor

gsuess commented Feb 21, 2015

the createDirective function takes two arguments: name and directiveParams, in that order. You have to pass these two arguments.

@madshargreave
Copy link
Author

Okay this is what I got

var guid     = guid();
var uploader = new Slingshot.Upload('fileUploads', { guid: guid });

uploader.send(file, function(error, downloadUrl) {

And then I have my directive

Slingshot.createDirective('fileUploads', Slingshot.S3Storage, {
  bucket: Meteor.settings.S3Bucket,
  region: Meteor.settings.AWSRegion,
  acl:       'public-read',

But I am not sure how to access the guid I passed in, inside the directive

@gsuess
Copy link
Contributor

gsuess commented Feb 21, 2015

Your key and authorize functions in the directive will take it as their 2nd argument.

key: function (fileInfo, metaInfo) {
   console.log(metaInfo.guid);
}

@madshargreave
Copy link
Author

I see, thanks

@gsuess gsuess closed this as completed Feb 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants