Closed nanek closed 13 years ago
Hi nanek,
This is possible, but in trying this out on my own, I have identified a bug specifically for the put/get to/from file operations. I'm fixing now and updating the user guide to make this type of thing better documented. I'll bump the version, post v0.0.3 to npm and respond with a longer message for your issue in just a bit.
Thanks, Ryan
In checking things out, I did discover some header bugs in get/put to/from file (basically, the headers/metadata wasn't being passed correctly). Please pull fresh from git or npm (which has been upgraded to v0.0.3 with the fix).
Sunny supports arbitrary HTTP headers in all operations. However, it doesn't yet support alternate operations / URLs (like GET/PUT acl/policy/etc). So for AWS, you can set an acl that is header-based, like on a PUT container/blob operation.
You code example is doing a blob (key) operation, but the documentation you are linking to is for a container (bucket). At any rate, it's analogous, so I'm assuming you just want to set "public-read" on the blob (image file).
The Blob.putFromFile guide notes all of the options you have for a request. (This is the sister method to Container.putBlobFromFile
and their signatures are:
Container.putBlobFromFile(name, filePath, options)
Blob.putFromFile(filePath, options)
The options
object has three relevant header options for almost all Sunny cloud operations:
headers
: Unmodified headers to send with the request.cloudHeaders
: Headers to append the cloud specific prefix (e.g., "x-amz-") to.metadata
: Headers to append the cloud-specific metadata prefix (e.g., "x-amz-meta-") to.So, for your request, it should be something like:
var request2 = containerObj.putBlobFromFile(imagename, imagepath, {
cloudHeaders: {
// Here's where your header should go.
// The "x-amz-" part is added by sunny.
'acl': 'public-read'
}
});
and that should correctly set the ACL on the object (at least it did when I was testing things out from my end).
Let me know if that doesn't solve your problem and we can re-open the issue.
Thanks! I tested the update and it works great!
http://docs.amazonwebservices.com/AmazonS3/latest/API/index.html?RESTBucketPUTacl.html I want the files I upload to be public readable. Im using the code below. Any tips on how to properly set this header? Is there a way to turn logging of the request?
var request2 = containerObj.putBlobFromFile( imagename, imagepath, null, null, {'x-amz-acl':'public-read'} );