Files
2026-04-15 15:23:57 +07:00

34 lines
910 B
PHP

<?php
class S3_api extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->load->library("Sas_s3");
}
function create_bucket($bucket)
{
$resp = $this->sas_s3->create_bucket($bucket);
}
function upload_file()
{
// global $_POST, $_FILES;
// $input_file= $_FILES["files"];
// $key = $_POST["xid"]. "-" . $input_file["name"];
// $contents = file_get_contents($input_file["tmp_name"]);
// $content_type = $input_file["type"];
$key = "xxid.txt";
$bucket = "audio-sample";
$content_type = "text/plain";
$contents = "this is a test only";
$resp = $this->sas_s3->upload($bucket, $key, $content_type, $contents);
echo "status : " . $resp['@metadata']['statusCode'];
print_r($resp);
}
function get_url($bucket, $xid)
{
$resp = $this->sas_s3->show_url($bucket, $xid, "30 seconds");
echo $resp . "\n";
}
}