|
| 1 | +<?php |
| 2 | +if (getenv('OBJECTSTORE_S3_BUCKET')) { |
| 3 | + $use_ssl = getenv('OBJECTSTORE_S3_SSL'); |
| 4 | + $use_path = getenv('OBJECTSTORE_S3_USEPATH_STYLE'); |
| 5 | + $use_legacyauth = getenv('OBJECTSTORE_S3_LEGACYAUTH'); |
| 6 | + $autocreate = getenv('OBJECTSTORE_S3_AUTOCREATE'); |
| 7 | + $CONFIG = array( |
| 8 | + 'objectstore' => array( |
| 9 | + 'class' => '\OC\Files\ObjectStore\S3', |
| 10 | + 'arguments' => array( |
| 11 | + 'bucket' => getenv('OBJECTSTORE_S3_BUCKET'), |
| 12 | + 'region' => getenv('OBJECTSTORE_S3_REGION') ?: '', |
| 13 | + 'hostname' => getenv('OBJECTSTORE_S3_HOST') ?: '', |
| 14 | + 'port' => getenv('OBJECTSTORE_S3_PORT') ?: '', |
| 15 | + 'storageClass' => getenv('OBJECTSTORE_S3_STORAGE_CLASS') ?: '', |
| 16 | + 'objectPrefix' => getenv("OBJECTSTORE_S3_OBJECT_PREFIX") ? getenv("OBJECTSTORE_S3_OBJECT_PREFIX") : "urn:oid:", |
| 17 | + 'autocreate' => (strtolower($autocreate) === 'false' || $autocreate == false) ? false : true, |
| 18 | + 'use_ssl' => (strtolower($use_ssl) === 'false' || $use_ssl == false) ? false : true, |
| 19 | + // required for some non Amazon S3 implementations |
| 20 | + 'use_path_style' => $use_path == true && strtolower($use_path) !== 'false', |
| 21 | + // required for older protocol versions |
| 22 | + 'legacy_auth' => $use_legacyauth == true && strtolower($use_legacyauth) !== 'false' |
| 23 | + ) |
| 24 | + ) |
| 25 | + ); |
| 26 | +
|
| 27 | + if (getenv('OBJECTSTORE_S3_KEY_FILE')) { |
| 28 | + $CONFIG['objectstore']['arguments']['key'] = trim(file_get_contents(getenv('OBJECTSTORE_S3_KEY_FILE'))); |
| 29 | + } elseif (getenv('OBJECTSTORE_S3_KEY')) { |
| 30 | + $CONFIG['objectstore']['arguments']['key'] = getenv('OBJECTSTORE_S3_KEY'); |
| 31 | + } else { |
| 32 | + $CONFIG['objectstore']['arguments']['key'] = ''; |
| 33 | + } |
| 34 | + |
| 35 | + if (getenv('OBJECTSTORE_S3_SECRET_FILE')) { |
| 36 | + $CONFIG['objectstore']['arguments']['secret'] = trim(file_get_contents(getenv('OBJECTSTORE_S3_SECRET_FILE'))); |
| 37 | + } elseif (getenv('OBJECTSTORE_S3_SECRET')) { |
| 38 | + $CONFIG['objectstore']['arguments']['secret'] = getenv('OBJECTSTORE_S3_SECRET'); |
| 39 | + } else { |
| 40 | + $CONFIG['objectstore']['arguments']['secret'] = ''; |
| 41 | + } |
| 42 | + |
| 43 | + if (getenv('OBJECTSTORE_S3_SSE_C_KEY_FILE')) { |
| 44 | + $CONFIG['objectstore']['arguments']['sse_c_key'] = trim(file_get_contents(getenv('OBJECTSTORE_S3_SSE_C_KEY_FILE'))); |
| 45 | + } elseif (getenv('OBJECTSTORE_S3_SSE_C_KEY')) { |
| 46 | + $CONFIG['objectstore']['arguments']['sse_c_key'] = getenv('OBJECTSTORE_S3_SSE_C_KEY'); |
| 47 | + } |
| 48 | +} |
0 commit comments