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

Ability to set custom AWS headers in addSave? #6

Open
eethann opened this issue Mar 18, 2013 · 1 comment
Open

Ability to set custom AWS headers in addSave? #6

eethann opened this issue Mar 18, 2013 · 1 comment

Comments

@eethann
Copy link

eethann commented Mar 18, 2013

Hey there,

We need to ensure that all images saved by Blitline have public read disabled, and are accessible only via expiring REST API URLs.

As discussed on the S3 Headers page, Blitline should be able to handle this. But it looks like custom headers are not yet supported by this module, is that correct?

I did a bit of digging and I can see the Save and S3_Destination classes, but I'm not clear how exactly to go about modifying the current save behavior to take an optional set of S3_headers should they exist.

Is there a way to use a plain addFunction call to save with additional vars? Is this feature something which might be released shortly?

Thanks,
Ethan

@blitline-dev
Copy link
Owner

The nice thing about Node is that it plays so nicely with JSON. The S3_Destination class only defines the requirements for a key and a destination, but any other field can be dynamically added to it just as in javascript. So for example, if you wanted to add a s3_destination that had custom header fields you could just do something along the lines of:

var blitline = new Blitline();
/* Replace MY_APP_ID with your Blitline application_id */
var job = blitline.addJob("MY_APP_ID", "http://www.google.com/intl/en_com/images/srpr/logo3w.png");
var crop_function = job.addFunction("resize_to_fill", { width: 50, height: 50}, "my_cropped_image");

var save = new Save();
save.image_identifier = "MY_IMAGE_IDENTIFIER";
var s3Destination = new S3Destination();
s3Destination.bucket = "my_bucket";
s3Destination.key = "my_key";
s3Destination.headers = [
              "x-amz-acl" :"private",
              "x-amz-meta-foo" : "some_other_metadata_we_might_want"
]
save.s3_destination = s3Destination;
crop_function.save = save
blitline.postJobs(function(response) {
  console.log(response);
});

All that being said, in the Blitline Ruby gem we have moved to simply defining the JSON and not trying to use an ORM to define a job, that only seems to take longer and is harder to change and keep updated. I will make a ticket to update the Node package with the ability to submit raw json instead of trying to build a job through objects.
For example, the item above ultimately just outputs the following to Blitline:

"application_id": "YOUR_APP_ID",
"src" : "http://www.google.com/intl/en_com/images/srpr/logo3w.png",
"functions" : [{
"name": "resize_to_fit",
"params" : { "width": 50, "height": 50 }
"save" : {
"image_identifier" : "YOUR_IMAGE_IDENTIFIER",
"s3_destination" : {
"bucket" : "my_bucket",
"key" : "my_key",
"headers" : {
"x-amz-acl" :"private",
"x-amz-meta-foo" : "some_metadata"
}
}
}
}]

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

No branches or pull requests

2 participants