error in uploading image using aws s3 bucket

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
dunesfactory02
User
Posts: 1

error in uploading image using aws s3 bucket

Post by dunesfactory02 »

Step 1 - I have added aws/aws-sdk-php by composer package , version : 3.297.3.
Step 2 - In server events -> global -> all pages -> added nameSpace_use -> use \Aws\S3\S3Client;
Step 3 - In server events -> global -> all pages -> Global Code -> added aws connection

putenv("AWS_ACCESS_KEY_ID=XXXXXXXXXXX");
    putenv("AWS_SECRET_ACCESS_KEY=XXXXXXXXXXX");
    putenv("AWS_CONFIG_FILE='/'");

    $s3client = new S3Client([
        "version" => "latest",
        "region" => "XXXXX",
        "AWS_BUCKET" => "XXXX",
        "AWS_USE_PATH_STYLE_ENDPOINT" => false,
        "http" => ["verify" => true] 
    ]);
    $s3client->registerStreamWrapper();

Step 4 - in advance setting option i have added
file-upload-path-absolute-for-temporary-files = temp
file-upload-url-path-absolute-for-temporary-files = (tried = /temp/ , http://localhost/my-project/temp )

in php settings -> upload path -> i have added - s3://my-bucket/
and in field upload path is - s3://my-bucket/user/
now when i am uploading image in add page i got added successfully but image is not found in s3 bucket. Please help me


arbei
User
Posts: 9384

Post by arbei »

dunesfactory02 wrote:

"AWS_BUCKET" => "XXXX",
"AWS_USE_PATH_STYLE_ENDPOINT" => false,

There are no such options, read AWS docs.

in php settings -> upload path -> i have added - s3://my-bucket/
and in field upload path is - s3://my-bucket/user/

If you use S3 folder for the field upload folder, you better a use a local folder for the global upload folder. If you must use S3 folder as global upload folder, you need to set both File upload path (absolute) for temporary files and File upload URL path (absolute) for temporary files.

Also make sure "my-bucket" is an existing bucket on your S3 server with read/write permission. Make sure the bucket name in your project settings matches exactly the real bucket name on your S3 account. (Obviously "my-bucket" is not a real bucket name.)


Post Reply