Example #1
0
<?php

include_once __DIR__ . "/../vendor/autoload.php";
$cache = dirname(__DIR__) . "/cache/";
$remoteFile = "test1/test1.txt";
$s3 = \JLaso\S3Wrapper\S3Wrapper::getInstance();
var_dump($s3->listBuckets());
$s3->saveFile($remoteFile, "text1");
var_dump($s3->getFilesList());
$f1 = $s3->getFileIfNewest($cache . "test1.txt", $remoteFile);
var_dump(file_get_contents($f1));
$s3->deleteFile($f1, $remoteFile);
Example #2
0
<?php

include __DIR__ . "/../vendor/autoload.php";
use JLaso\S3Wrapper\S3Wrapper;
$awsKey = $awsSecret = $bucket = $current = $localFile = "";
$files = array();
if (isset($_POST['aws-key']) && isset($_POST['aws-secret']) && isset($_POST['bucket'])) {
    $awsKey = $_POST['aws-key'];
    $awsSecret = $_POST['aws-secret'];
    $bucket = $_POST['bucket'];
    $s3 = new S3Wrapper($awsKey, $awsSecret, $bucket);
    $files = $s3->getFilesList("");
    if (isset($_POST['file']) && !empty($_POST['file'])) {
        $current = $_POST['file'];
        $localFile = __DIR__ . "/../cache/" . str_replace("/", "_", $current);
        $s3->getFileIfNewest($localFile, $current);
    }
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="favicon.ico?v=1"/>
    <title>AWS S3 online demo by JLaso</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" integrity="sha512-dTfge/zgoMYpP7QbHy4gWMEGsbsdZeCXz7irItjcC3sPUFtf0kuFbDz/ixG7ArTxmDjLXDmezHubeNikyKGVyQ==" crossorigin="anonymous">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css" integrity="sha384-aUGj/X2zp5rLCbBxumKTCw2Z50WgIr1vs/PFN4praOTvYXWlVyh2UtNUU0KAUhAX" crossorigin="anonymous">
    <link rel="stylesheet" href="css/styles.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>