-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
54 lines (41 loc) · 1.4 KB
/
index.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
declare(strict_types=1);
require __DIR__.'/vendor/autoload.php';
use League\Flysystem\Filesystem;
use Overtrue\Flysystem\Qiniu\QiniuAdapter;
use PCIT\Plugin\Toolkit\Core;
$core = new Core();
$config = [
'app_id' => getenv('INPUT_APP_ID'),
'secret_id' => getenv('INPUT_SECRET_ID'),
'secret_key' => getenv('INPUT_SECRET_KEY'),
'region' => getenv('INPUT_REGION'),
'timeout' => 60,
];
$bucket = getenv('INPUT_BUCKET');
$endpoint = getenv('INPUT_ENDPOINT');
$accessKey = getenv('INPUT_ACCESS_KEY');
$secretKey = getenv('INPUT_SECRET_KEY');
try {
$adapter = new QiniuAdapter($accessKey, $secretKey, $bucket, $endpoint);
$flysystem = new Filesystem($adapter);
$input_files = getenv('INPUT_FILES');
// obj
if (is_object(json_decode($input_files))) {
foreach (json_decode($input_files, true) as $file => $label) {
$result = $flysystem->writeln($label, file_get_contents($file));
$core->debug("Upload [ $file ] TO [ $label ]");
$core->debug((string) $result);
}
// array
} else {
$files = explode(',', $input_files);
foreach ($files as $file) {
$result = $flysystem->writeln($file, file_get_contents($file));
$core->debug("Upload [ $file ] TO [ $file ]");
$core->debug((string) $result);
}
}
} catch (Throwable $e) {
$core->debug($e->__toString());
}