0

我正在尝试使用前端 uppy.io 实现 TUS 可恢复文件上传。在我使用 XHR 上传之前,它工作正常。当我使用 tus 在本地机器上上传时,它可以工作,但我需要在 s3 上上传。前端代码。

var uppy = Uppy.Core()
.use(Uppy.Dashboard, {inline: true,formData: true,height: 350,target: '#drag-drop-area'})
.use(Uppy.Tus, {endpoint: '<?=base_url()?>files',resume: true,autoRetry: true,retryDelays: [0, 1000, 3000, 5000,10000]})
.use(Uppy.GoogleDrive, { target: Uppy.Dashboard, companionUrl: '...xyz...',companionAllowedHosts: "...xyz..." })
.use(Uppy.Dropbox, { target: Uppy.Dashboard, companionUrl: '...xyz...' })
uppy.on('complete', (result) => {
        console.log('Upload complete! We’ve uploaded these files:', result)
})

我正在使用 CodeIgniter 使用上传方法创建 Tus 控制器。和更新的路线

$route['files'] = 'Tus/upload';
$route['files/(:any)'] = 'Tus/upload/$1';

上传方法包含代码:

$awsAccessKey = ''; // YOUR AWS ACCESS KEY
$awsSecretKey = ''; // YOUR AWS SECRET KEY
$awsRegion    = 'us-west-1';      // YOUR AWS BUCKET REGION
$basePath     = 's3://abcxyz';
$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);

上传已成功完成,但我得到的是 localhost 上传的 URL 而不是 s3。

在此处输入图像描述

我究竟做错了什么??请帮忙。

参考 :

uppy.io

混帐

4

0 回答 0