Source: get.php
⬇️ Tải file Trang chính
<?php
require __DIR__.'/s3helper.php';
$cfg=s3_load_config();
$key=ltrim((string)($_GET['key']??''),'/');

if($key===''){
?><!doctype html><html><head><meta charset="utf-8"><title>Download</title>
<style>body{font-family:Inter,Arial;background:#fafafa;padding:20px}input,button{padding:8px;margin:6px}</style></head>
<body><h2>⬇️ Download từ bucket: <?=htmlspecialchars($cfg['bucket'])?></h2>
<form method="get"><input name="key" placeholder="vd: images/2025/photo.jpg" required style="width:360px"> <button>Tải</button></form>
<p><a href="index.php">← Trang chính</a> • <a href="view_source.php?file=get.php" target="_blank">Source</a></p></body></html>
<?php exit; }

$r=s3_send_request($cfg,'GET',$cfg['bucket'],$key,[],[],null);
if(!$r['ok']){
  header('Content-Type:text/plain; charset=utf-8',true,$r['http_code']);
  echo "Error HTTP {$r['http_code']}\n";
  echo $r['body'];
  exit;
}
$h=$r['headers'];
if(!empty($h['content-type'])) header('Content-Type: '.$h['content-type']);
if(!empty($h['content-length'])) header('Content-Length: '.$h['content-length']);
if(!empty($h['etag'])) header('ETag: '.$h['etag']);
header('Content-Disposition: inline; filename="'.basename($key).'"');
echo $r['body'];