csvをs3にアップロードしよう

composerを入れます。
[vagrant@localhost s3]$ curl -sS https://getcomposer.org/installer | php

aws sdkをインストール
[vagrant@localhost s3]$ php composer.phar require aws/aws-sdk-php

consoleでs3のバケットを作成する。

upload

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
require_once('vendor/autoload.php');
 
$s3client = new Aws\S3\S3Client([
    'credentials' => [
        'key' => 'A',
        'secret' => ''
    ],
    'region' => 'ap-northeast-1',
    'version' => 'latest',
]);
 
$result = $s3client->putObject([
    'Bucket' => '',
    'Key' => 'article.csv',
    'SourceFile' => 'article.csv',
    'ContentType' => mime_content_type('article.csv'),
]);

おいおいおい、まじかー

まじかー。2回言ってしまった。

次はuploadしたS3のバケットからCSVをダウンロードして、mysqlの異なるdb・tableにinsertする。