ankitpokhrel / ankitpokhrel/tus-php

Please kindly explain this code to me

Abierto
#429 1 comentario 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
PHP
Estrellas
1.5k
Forks
220
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

```
// 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?

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.