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
|
<?php
$config = [
'credentials' => [
'key' => 'minioadmin',
'secret' => 'minioadmin',
],
'region' => 'ap-northeast-1',
'version' => 'latest',
'endpoint' => 'https://ローカルIPアドレス:9001',
'use_path_style_endpoint' => true,
'scheme' => 'http'
];
$s3 = new Aws\S3\S3Client( $config );
$path = '/sample/sample.json';
$option = [
'Bucket' => 'sample-Buket',
'Key' => $path
];
// 有効期限付きURLで取得する
$response = $s3->getCommand( 'GetObject', $option);
$request = $s3->createPresignedRequest( $response, '+5 minutes'); // 有効期限 5分すぎると無効になる
$url = (string)$request->getUri();
// ローカル環境対策のSSL証明チェック無効設定
$context = stream_context_create([
'http' => [
'timeout' => 30,
'ignore_errors' => true
],
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false
]
]);
// ファイルを一旦UTF-8に変換する
$data = file_get_contents($obj, false, $context); // ← データの取得ができる
$data = mb_convert_encoding( $data, 'UTF-8', 'SJIS-win,UTF-8,eucJP-win' );
$oResponse = json_decode( $data, true, 512, JSON_THROW_ON_ERROR );
|