Using External Code in a Plugin

Hello,

I am using the Website Comments plugin and currently users can upload files with their posts. The files are uploaded to the app server however I would like to upload the files to S3.

We already have the S3 file upload functionality working well in other areas of the site. The main file is at /cmsb/lib/s3_functions.php

So I would like to include this file in the websiteComments.php code but when I try the following it does not work:

include_once(__DIR__ .'/../../lib/s3_functions.php');

I receive this error:

#85 - UNCAUGHT_EXCEPTION: Credentials must be an instance of Aws\Credentials\CredentialsInterface, an associative array that contains "key", "secret", and an optional "token" key-value pairs, a credentials provider function, or false./var/www/html/php/dev/cmsb/vendor/aws/aws-sdk-php/src/ClientResolver.php (line 419)http://dev.test/bulletin_board.php

I'm not sure why we are able to upload to S3 on normal "list" and "detail" pages but can't get this to work when used in a plugin. Is there something like a hook that needs to be written?

If anyone could offer some advice that would be great!

Thank you,
Greg

By Jenna - January 27, 2021

Hi Greg,

Thanks for posting your solution, it may be helpful to others in the future. I'm glad you were able to sort it out on your own.

Have a great day!

Jenna Cooke - PHP Programmer
interactivetools.com