@@ -91,7 +91,7 @@ public function __construct($config) {
91
91
* @return array
92
92
*/
93
93
public function __sleep () {
94
- return array ( 'bucket ' ) ;
94
+ return [ 'bucket ' ] ;
95
95
}
96
96
97
97
/**
@@ -150,17 +150,17 @@ public function set_client($config) {
150
150
return ;
151
151
}
152
152
153
- $ options = array (
153
+ $ options = [
154
154
'region ' => $ config ->s3_region ,
155
- 'version ' => AWS_API_VERSION
156
- ) ;
155
+ 'version ' => AWS_API_VERSION ,
156
+ ] ;
157
157
158
158
if (empty ($ config ->s3_usesdkcreds )) {
159
- $ options ['credentials ' ] = array ( 'key ' => $ config ->s3_key , 'secret ' => $ config ->s3_secret ) ;
159
+ $ options ['credentials ' ] = [ 'key ' => $ config ->s3_key , 'secret ' => $ config ->s3_secret ] ;
160
160
}
161
161
162
162
if ($ config ->useproxy ) {
163
- $ options ['http ' ] = array ( 'proxy ' => $ this ->get_proxy_string ()) ;
163
+ $ options ['http ' ] = [ 'proxy ' => $ this ->get_proxy_string ()] ;
164
164
}
165
165
166
166
// Support base_url config for aws api compatible endpoints.
@@ -196,9 +196,9 @@ private function get_md5_from_hash($contenthash) {
196
196
197
197
try {
198
198
$ key = $ this ->get_filepath_from_hash ($ contenthash );
199
- $ result = $ this ->client ->headObject (array (
199
+ $ result = $ this ->client ->headObject ([
200
200
'Bucket ' => $ this ->bucket ,
201
- 'Key ' => $ this ->bucketkeyprefix . $ key) );
201
+ 'Key ' => $ this ->bucketkeyprefix . $ key] );
202
202
} catch (\Aws \S3 \Exception \S3Exception $ e ) {
203
203
return false ;
204
204
}
@@ -265,11 +265,11 @@ public function rename_file($currentpath, $destinationpath) {
265
265
* @return mixed
266
266
*/
267
267
public function get_seekable_stream_context () {
268
- $ context = stream_context_create (array (
269
- 's3 ' => array (
270
- 'seekable ' => true
271
- )
272
- ) );
268
+ $ context = stream_context_create ([
269
+ 's3 ' => [
270
+ 'seekable ' => true ,
271
+ ],
272
+ ] );
273
273
return $ context ;
274
274
}
275
275
@@ -303,7 +303,7 @@ public function test_connection() {
303
303
$ connection ->success = false ;
304
304
$ connection ->details = get_string ('settings:notconfigured ' , 'tool_objectfs ' );
305
305
} else {
306
- $ this ->client ->headBucket (array ( 'Bucket ' => $ this ->bucket ) );
306
+ $ this ->client ->headBucket ([ 'Bucket ' => $ this ->bucket ] );
307
307
}
308
308
} catch (\Aws \S3 \Exception \S3Exception $ e ) {
309
309
$ connection ->success = false ;
@@ -331,29 +331,29 @@ public function test_connection() {
331
331
public function test_permissions ($ testdelete ) {
332
332
$ permissions = new \stdClass ();
333
333
$ permissions ->success = true ;
334
- $ permissions ->messages = array () ;
334
+ $ permissions ->messages = [] ;
335
335
336
336
if ($ this ->is_functional ()) {
337
337
$ permissions ->success = false ;
338
- $ permissions ->messages = array () ;
338
+ $ permissions ->messages = [] ;
339
339
return $ permissions ;
340
340
}
341
341
342
342
try {
343
- $ result = $ this ->client ->putObject (array (
343
+ $ result = $ this ->client ->putObject ([
344
344
'Bucket ' => $ this ->bucket ,
345
345
'Key ' => $ this ->bucketkeyprefix . 'permissions_check_file ' ,
346
- 'Body ' => 'test content ' ) );
346
+ 'Body ' => 'test content ' ] );
347
347
} catch (\Aws \S3 \Exception \S3Exception $ e ) {
348
348
$ details = $ this ->get_exception_details ($ e );
349
349
$ permissions ->messages [get_string ('settings:writefailure ' , 'tool_objectfs ' ) . $ details ] = 'notifyproblem ' ;
350
350
$ permissions ->success = false ;
351
351
}
352
352
353
353
try {
354
- $ result = $ this ->client ->getObject (array (
354
+ $ result = $ this ->client ->getObject ([
355
355
'Bucket ' => $ this ->bucket ,
356
- 'Key ' => $ this ->bucketkeyprefix . 'permissions_check_file ' ) );
356
+ 'Key ' => $ this ->bucketkeyprefix . 'permissions_check_file ' ] );
357
357
} catch (\Aws \S3 \Exception \S3Exception $ e ) {
358
358
$ errorcode = $ e ->getAwsErrorCode ();
359
359
// Write could have failed.
@@ -368,7 +368,7 @@ public function test_permissions($testdelete) {
368
368
try {
369
369
$ result = $ this ->client ->deleteObject ([
370
370
'Bucket ' => $ this ->bucket ,
371
- 'Key ' => $ this ->bucketkeyprefix . 'permissions_check_file '
371
+ 'Key ' => $ this ->bucketkeyprefix . 'permissions_check_file ' ,
372
372
]);
373
373
$ permissions ->messages [get_string ('settings:deletesuccess ' , 'tool_objectfs ' )] = 'warning ' ;
374
374
$ permissions ->success = false ;
@@ -536,7 +536,7 @@ public function support_presigned_urls() {
536
536
* @return signed_url
537
537
* @throws \Exception
538
538
*/
539
- public function generate_presigned_url ($ contenthash , $ headers = array () ) {
539
+ public function generate_presigned_url ($ contenthash , $ headers = [] ) {
540
540
if ('cf ' === $ this ->signingmethod ) {
541
541
return $ this ->generate_presigned_url_cloudfront ($ contenthash , $ headers );
542
542
}
@@ -825,18 +825,18 @@ public function curl_range_request_to_presigned_url($contenthash, $ranges, $head
825
825
} catch (\Exception $ e ) {
826
826
throw new \coding_exception ('Failed to generate pre-signed url: ' . $ e ->getMessage ());
827
827
}
828
- $ headers = array (
828
+ $ headers = [
829
829
'Range: bytes= ' . $ ranges ->rangefrom . '- ' . $ ranges ->rangeto ,
830
- ) ;
830
+ ] ;
831
831
$ curl = new \curl ();
832
- $ curl ->setopt (array ( 'CURLOPT_HTTP_VERSION ' => CURL_HTTP_VERSION_1_1 ) );
833
- $ curl ->setopt (array ( 'CURLOPT_RETURNTRANSFER ' => true ) );
834
- $ curl ->setopt (array ( 'CURLOPT_SSL_VERIFYPEER ' => false ) );
835
- $ curl ->setopt (array ( 'CURLOPT_CONNECTTIMEOUT ' => 15 ) );
836
- $ curl ->setopt (array ( 'CURLOPT_TIMEOUT ' => 15 ) );
832
+ $ curl ->setopt ([ 'CURLOPT_HTTP_VERSION ' => CURL_HTTP_VERSION_1_1 ] );
833
+ $ curl ->setopt ([ 'CURLOPT_RETURNTRANSFER ' => true ] );
834
+ $ curl ->setopt ([ 'CURLOPT_SSL_VERIFYPEER ' => false ] );
835
+ $ curl ->setopt ([ 'CURLOPT_CONNECTTIMEOUT ' => 15 ] );
836
+ $ curl ->setopt ([ 'CURLOPT_TIMEOUT ' => 15 ] );
837
837
$ curl ->setHeader ($ headers );
838
838
$ content = $ curl ->get ($ url );
839
- return array ( 'responseheaders ' => $ curl ->getResponse (), 'content ' => $ content , 'url ' => $ url) ;
839
+ return [ 'responseheaders ' => $ curl ->getResponse (), 'content ' => $ content , 'url ' => $ url] ;
840
840
}
841
841
842
842
/**
0 commit comments