Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • raifs Friend
    #158196

    Hi, is there an easy way to send files to amazon s3 with Expires header?
    Thanks in advance.

    Thanh Nguyen Viet Friend
    #369750

    Hello mate,

    Header-Expires is automatically added by Amazon SDK.

    Best regards,
    ThanhNV

    raifs Friend
    #370003

    I 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?

    raifs Friend
    #370004

    Thanks for the previous reply (forgot to mention)

    raifs Friend
    #370007

    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?

    raifs Friend
    #370019

    any help on this?

    raifs Friend
    #370033

    Ok. 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 Friend
    #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

Viewing 8 posts - 1 through 8 (of 8 total)

This topic contains 8 replies, has 2 voices, and was last updated by  Thanh Nguyen Viet 13 years, 3 months ago.

We moved to new unified forum. Please post all new support queries in our New Forum