PHP code example of jvalousek / aws-sdk-nette-s3-ec2-extension

1. Go to this page and download the library: Download jvalousek/aws-sdk-nette-s3-ec2-extension library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jvalousek / aws-sdk-nette-s3-ec2-extension example snippets


class S3Service
{

	/**
	 * @var \Aws\S3\S3Client
	 */
	public $s3;


	public function __construct(\Aws\S3\S3Client $s3)
	{
		$this->s3 = $s3;
	}


	public function save($path_to_file)
	{
		$this->s3->putObject([
			'Bucket'     => 'YourBucket',
			'Key'        => 'YourObjectKey',
			'SourceFile' => $path_to_file,
		]);
	}

}

class HomepagePresenter extends Presenter
{

	/**
	 * @var S3Service
	 * @inject
	 */
	public $service;


	public function actionDefault()
	{
		$this->service->save('/path/to/file');
	}

}