amal
amal

Reputation: 1

AWS S3 file upload access denied in php codeigniter

unable to upload files to aws s3 bucket shows " A PHP Error was encountered Severity: User Warning

Message: S3::putObject(): [AccessDenied] Access Denied

Filename: libraries/S3.php"

Upvotes: 0

Views: 1086

Answers (1)

pati51
pati51

Reputation: 315

There are two ways to solve this problem-

  1. If your Bucket permission "Bucket and object not public" First, you need to change the permission in AWS S3 Go to Bucket->permission->edit

Uncheck

- Block new public ACLs and uploading public object
- Remove public access granted through public ACLs

Now try to upload, I hope it will work.

  1. Use "S3::ACL_PRIVATE" in your putObjectFile function parameter at the time of upload file. ACL_PRIVATE and other keys are declared in the s3.php library file.

    $saved = $this->s3->putObjectFile($file_path,
             $this->bucket_name,
             $this->folder_name.$s3_file,
             S3::ACL_PRIVATE,
             array(),
             $mime_type);
    

Now try to upload.

Upvotes: 1

Related Questions