示例#1
0
文件: s3-add-cache.php 项目: rjha/sc
    // thumbnail - for bkp1.3mik.com - 2000, for media1.3mik.com - 2000
    // run for stored_name and thumbnail 
*/
$total = 2000;
$pageSize = 50;
$pages = ceil($total / $pageSize);
$count = 0;
while ($count <= $pages) {
    $start = $count * $pageSize + 1;
    $end = $start + ($pageSize - 1);
    $sql = " select * from sc_media where  (id <= {end}) and (id >= {start} ) ";
    $sql = str_replace(array("{end}", "{start}"), array(0 => $end, 1 => $start), $sql);
    $rows = MySQL\Helper::fetchRows($mysqli, $sql);
    printf("processing media rows between %d and %d \n", $start, $end);
    foreach ($rows as $row) {
        //$s3name = $row["stored_name"];
        $s3name = $row["thumbnail"];
        $name = $row["original_name"];
        $rowId = $row["id"];
        // get mime from name.
        $mime = \com\indigloo\Util::getMimeFromName($name);
        if (empty($mime)) {
            //report it
            printf("Bad mime type for media id %d \n", $rowId);
            $mime = "application/octet-stream";
        }
        add_object_headers($s3, $bucket, $s3name, $rowId, $mime);
        sleep(1);
    }
    $count++;
}