![]() |
Need help connecting to Amazon S3 storage - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: Need help connecting to Amazon S3 storage (/showthread.php?tid=79469) Pages:
1
2
|
Need help connecting to Amazon S3 storage - chakycool - 06-21-2021 Hi, I'm trying to connect with Amazon S3 and the libraries that are available works only with CI3. Can some one please direct me to CI4 library or any support. RE: Need help connecting to Amazon S3 storage - craig - 06-21-2021 The official AWS SDK for PHP, installed via Composer, works fine with CI 4. It can be registered and used with CI4 services: Code: /* In Config/Services.php: */ Code: <?php Code: # in your .env RE: Need help connecting to Amazon S3 storage - chakycool - 06-23-2021 Thanks Craig, got the SDK setup. When I'm using the upload method I'm getting memory error. Can you please point out what I'm doing wrong. Code $aws = service('aws')->createClient('S3',['version' => '2006-03-01']); $aws->upload($bucketName, $uploadFileName, $file); Error: ErrorException #1 Allowed memory size of 134217728 bytes exhausted (tried to allocate 65015808 bytes) RE: Need help connecting to Amazon S3 storage - craig - 06-23-2021 Not sure where that's coming from, or where the upload() method exists. All the docs point to the PutObject() method to upload a file - https://docs.aws.amazon.com/code-samples/latest/catalog/php-s3-s3-uploading-object.php.html RE: Need help connecting to Amazon S3 storage - chakycool - 06-23-2021 Hi Craig, Tried the putObject() but I still get this memory error. $aws->putObject(['Body' => $file, 'Bucket' => $bucketName, 'Key' => $uploadName, 'ACL' => 'public-read']); RE: Need help connecting to Amazon S3 storage - craig - 06-23-2021 Can you try uploading a much smaller file to see if you still have the same problem? You may need to increase the memory limit in your PHP configuration. RE: Need help connecting to Amazon S3 storage - chakycool - 06-24-2021 Hi Craig, I actually got this S3 library "https://github.com/tpyo/amazon-s3-php-class" to work on CI4 when I couldn't find anything specific to CI4. When you shared the info on how to use this via the official SDK you got me interested. Now the file tested to upload is less that 50Kb and get upload properly via the custom S3 library. The same file gives me a error when I try it via the SDK method. It would nice we I can get it to work via the SDK. RE: Need help connecting to Amazon S3 storage - craig - 06-25-2021 That library looks really old. With the limited error details you've provided so far, I'm still not sure why you're getting that error using the official SDK. I've used it on CI3 and CI4 projects and haven't come across that specific problem. RE: Need help connecting to Amazon S3 storage - chakycool - 06-27-2021 Hi Craig, I created the service file as you have mentioned above and then I loaded it to the controller. Here is the code in the controller. (Error screenshot is attached.) PHP Code: class Gift extends \App\Controllers\BaseController RE: Need help connecting to Amazon S3 storage - superior - 06-28-2021 (06-27-2021, 03:22 AM)chakycool Wrote: Hi Craig,Try sending it to a .txt file to see what output it gives, most likely it's to big to print on your screen. Encountered this myself a few times, learned to put it in an empty .txt so i can read it when the request is done. |