ankitpokhrel / ankitpokhrel/tus-php
Please kindly explain this code to me
- Lingua principale
- PHP
- Stelle
- 1.5k
- Fork
- 220
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
```
// server.php
// composer require aws/aws-sdk-php
use Aws\S3\S3Client;
use TusPhp\Tus\Server;
use Aws\Credentials\Credentials;
$awsAccessKey = 'AWS_ACCESS_KEY'; // YOUR AWS ACCESS KEY
$awsSecretKey = 'AWS_SECRET_KEY'; // YOUR AWS SECRET KEY
$awsRegion = 'eu-west-1'; // YOUR AWS BUCKET REGION
$basePath = 's3://your-bucket-name';
$s3Client = new S3Client([
'version' => 'latest',
'region' => $awsRegion,
'credentials' => new Credentials($awsAccessKey, $awsSecretKey)
]);
$s3Client->registerStreamWrapper();
$server = new Server('file');
$server->setUploadDir($basePath);
$response = $server->serve();
$response->send();
exit(0);
```
My question is that how does the file gets transfered to s3 storage because I can see that $s3Client is not been used in Server() constructor, then how does $s3Client know where the file is for upload. The setUploadDir($basePath); is only using the basePath of the s3 location but not the $s3Client. Its not possible to use just the basepath to upload file to s3 without authorization.
Please i need clear explanations on how the code works above or is the code not complete?
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Valutazione
Questa issue non è ancora stata valutata.