Home

Custom upload headers for S3


You can add your own headers to your image if you push it to S3.
Amazon S3 support numerous headers as well as custom metadata headers
http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTObjectPUT.html


Default Headers:


By default (without Canonical ID set), Blitline sets two headers on uploaded files:


'x-amz-acl' : 'public-read' which makes it publicly readable.
'content-type' : 'image/jpg' which identifies what type of file it is (it can also be 'image/png')

By default (with Canonical ID set), Blitline sets two headers on uploaded files:


"x-amz-grant-read" : "uri=http://acs.amazonaws.com/groups/global/AllUsers" which makes it publicly readable.
"x-amz-grant-full-control" : "id=<CANONICAL ID>" which sets the owner to the canonical id owner
"content-type":"image/jpg" which identifies what type of file it is (it can also be 'image/png')

Notes:


To set your S3 objects to be private by default, set the header:
"x-amz-grant-read" : ""
Which will remove any read permissions from the object.


Adding Your Own Headers:


If you want to add your own header, you can add a "headers" JSON field to the s3_destination. This will add to or overwrite the existing default headers (so, for example, you can set the 'x-amz-acl' to not be public readable)
 
Here is an example of setting a custom header:
"json" : '{
  "application_id": "YOUR_APP_ID",
  "src" : "http://www.google.com/logos/2011/houdini11-hp.jpg",
  "functions" : [{
      "name": "blur",
      "save" : {
          "image_identifier" : "YOUR_IMAGE_IDENTIFIER",
          "s3_destination" : {
              "bucket" : "YOUR_BUCKET_NAME",
              "key" : "key value to save image as",
              "headers" : {
                  "x-amz-grant-read" :"", # This will make the object private
                  "x-amz-meta-foo" : "some_metadata"
              }
          }
      }
    }]
  }'