-
AuthorPosts
-
January 2, 2011 at 7:03 pm #158196
Hi, is there an easy way to send files to amazon s3 with Expires header?
Thanks in advance.Thanh Nguyen Viet FriendThanh Nguyen Viet
- Join date:
- September 2014
- Posts:
- 1461
- Downloads:
- 0
- Uploads:
- 44
- Thanked:
- 258 times in 217 posts
January 3, 2011 at 3:38 am #369750Hello mate,
Header-Expires is automatically added by Amazon SDK.
Best regards,
ThanhNVJanuary 4, 2011 at 11:47 am #370003I do not see Header-Expires on files that go to Amazon through jaamazons3. I have to manually add them using CloudBerry. Now I do not wish to add those headers every time jaamazons3 updates my bucket. So is there some file I can edit/modify to set Cache-Control and Exires to the files jaamazons3 sends to my bucket?
January 4, 2011 at 11:48 am #370004Thanks for the previous reply (forgot to mention)
January 4, 2011 at 12:01 pm #370007I did a little digging: in the localrepo.php there are some lines (starting from 425):
$opts = array(
‘filename’ => $filename,
‘body’ => $content,
‘contentType’ => ja_get_mime_content_type($file),
‘acl’ => AmazonS3::ACL_PUBLIC
);
$s3->create_object($profile->bucket_name, $filename, $opts);as I underestand this is where amazon s3 object creation starts – should i put there something like ‘headers’ => “Expires… something – I don’t know what”,
am i on the right tracks?
January 4, 2011 at 2:31 pm #370019any help on this?
January 4, 2011 at 3:24 pm #370033Ok. I made some changes and now jaamazons2 component sends files to Amazon S3 with Expires and Cache-Control.
I changed two files. localrepo.php and s3.class.php
In localrepo.php:
After line 427 added:
‘expires’ => “Mon, 31 Dec 2040 23:00:00 GMT”,
‘cache-control’ => “public”,
In s3.class.php:
After line 1260 added:
// Handle Expires. Can also be passed as an HTTP header.
if (isset($opt[‘expires’]))
{
$opt[‘headers’][‘Expires’] = $opt[‘expires’];
unset($opt[‘expires’]);
}// Handle Cache-Control. Can also be passed as an HTTP header.
if (isset($opt[‘cache-control’]))
{
$opt[‘headers’][‘Cache-Control’] = $opt[‘cache-control’];
unset($opt[‘cache-control’]);
}Appreciate if someone looks it over and comments if i did something wrong (right).
Cheers!
Thanh Nguyen Viet FriendThanh Nguyen Viet
- Join date:
- September 2014
- Posts:
- 1461
- Downloads:
- 0
- Uploads:
- 44
- Thanked:
- 258 times in 217 posts
January 5, 2011 at 3:59 am #370132<em>@raifs 212659 wrote:</em><blockquote>I did a little digging: in the localrepo.php there are some lines (starting from 425):
$opts = array(
‘filename’ => $filename,
‘body’ => $content,
‘contentType’ => ja_get_mime_content_type($file),
‘acl’ => AmazonS3::ACL_PUBLIC
);
$s3->create_object($profile->bucket_name, $filename, $opts);as I underestand this is where amazon s3 object creation starts – should i put there something like ‘headers’ => “Expires… something – I don’t know what”,
am i on the right tracks?</blockquote>
Please replace above code with :
$content = file_get_contents($file);
$opts = array(
'filename' => $filename,
'body' => $content,
'contentType' => ja_get_mime_content_type($file),
'acl' => AmazonS3::ACL_PUBLIC,
'headers' => array(
'Expires' => 'set your time here',
'Cache-Control' => 'set your cache option here'
)
);
$s3->create_object($profile->bucket_name, $filename, $opts);Best regards,
ThanhNV -
AuthorPosts
This topic contains 8 replies, has 2 voices, and was last updated by Thanh Nguyen Viet 13 years, 11 months ago.
We moved to new unified forum. Please post all new support queries in our New Forum