Reputation: 1633
I have an amazon s3 bucket that has 20+ records in it. How to get all file names with pagination support using PHP codeigniter.
Thanks in advance!
Upvotes: 0
Views: 2346
Reputation: 57312
First you need to get all object by listObjects
$result = $s3->listObjects([
'Bucket' => 'your-bucket-name'
]);
it will return array of objects and with links( if your bucket is public than you can open those link else you need to use signed url or cloudfront )
And i would simply suggest you to use dataTable (it has pagination, Search ) and your record is not like 30-40k so it will work fine
As you have asked you can bucket object list by passing key and secret in constructor, i am using aws phpsdk v3
s3 = new Aws\S3\S3Client([
'version' => 'latest',
'region' => 'us-west-2',
'credentials.ini' => [
'key' => $credentials['key'],
'secret' => $credentials['secret'],
],
]);
Now just
$result = $s3->listObjects([
'Bucket' => 'your-bucket-name'
]);
That's it you got array of all object in your bucket
Upvotes: 2