-
Notifications
You must be signed in to change notification settings - Fork 0
/
server2.php
40 lines (35 loc) · 900 Bytes
/
server2.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
/**
* サーバ側の処理
*/
require_once __DIR__.'/vendor/autoload.php';
require_once __DIR__."/AwsS3.php";
require_once __DIR__."/config.php";
if (!isset($_GET['command'])) {
exit;
}
$s3 = new AwsS3($config);
switch ($_GET['command']) {
case 'CreateMultipartUpload':
$file_name = basename($_GET['fileInfo']['name']);
$s3->echoInfoCreateMultipartUploadAndExit($file_name, $_GET['lengthes']);
break;
case 'CompleteMultipartUpload':
$sendBackData = $_GET['sendBackData'];
$s3->completeMultipartUpload($sendBackData['key'], $sendBackData['uploadId']);
header('Content-Type: application/json');
echo json_encode(array(
'status' => 'success',
));
exit;
break;
case 'download':
$keys = $s3->getListKeys();
if (count($keys) == 0) {
echo "file not found!";
exit;
}
header('Location: '.$s3->getUrlDirectDownload($keys[0]));
exit;
break;
}