Commit aeeca8be9f610f4fac827fdf7f19d1c41f705b2a
Exists in
master
Merge pull request #78 from ieducativa/corrige-config-s3
Corrigido configuração AWS S3 usada para upload de fotos.
Showing
1 changed file
with
14 additions
and
10 deletions
Show diff stats
ieducar/intranet/s3_config.php
| 1 | 1 | <?php |
| 2 | -// Bucket Name | |
| 3 | -require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/bootstrap.php'; | |
| 4 | 2 | |
| 5 | -$bucket= $GLOBALS['coreExt']['Config']->app->aws->bucketname; | |
| 6 | -$directory=$GLOBALS['coreExt']['Config']->app->database->dbname.'/'; | |
| 7 | -$key = $GLOBALS['coreExt']['Config']->app->aws->awsacesskey; | |
| 8 | -$secretKey = $GLOBALS['coreExt']['Config']->app->aws->awssecretkey; | |
| 3 | +$config = $GLOBALS['coreExt']['Config']->app; | |
| 9 | 4 | |
| 10 | -if (!class_exists('S3')) | |
| 11 | - require_once 'S3.php'; | |
| 5 | +$bucket = $config->aws->bucketname; | |
| 6 | +$directory = $config->database->dbname.'/'; | |
| 7 | +$key = $config->aws->awsacesskey; | |
| 8 | +$secretKey = $config->aws->awssecretkey; | |
| 12 | 9 | |
| 13 | -//instantiate the class | |
| 14 | -$s3 = new S3($key, $secretKey); | |
| 10 | +if (empty($bucket) || empty($key) || empty($secretKey)) { | |
| 11 | + throw new Exception("Defina as configs AWS."); | |
| 12 | +} | |
| 13 | + | |
| 14 | +if (!class_exists('S3')) { | |
| 15 | + require_once 'S3.php'; | |
| 16 | +} | |
| 15 | 17 | |
| 18 | +$s3 = new S3($key, $secretKey); | |
| 16 | 19 | $s3->putBucket($bucket, S3::ACL_PUBLIC_READ); |
| 20 | + | |
| 17 | 21 | ?> |
| 18 | 22 | \ No newline at end of file | ... | ... |