ankitpokhrel / ankitpokhrel/tus-php

Please kindly explain this code to me

Open
#429 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
1.5k
Forks
220
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.