Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

261
Vistas
unable to upload file to sub-folder of main bucket

I am trying to upload error file in AWSS3 but it shows error like "The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint: "test9011960909.s3.amazonaws.com"."

i also specified 'region' => 'us-east-1' but still same error occurs.

it is working when i specify

'Bucket'       => $this->bucket,

but i wanted to upload file in sub-folder of main bucket

'Bucket'       => $this->bucket . "/" . $PrefixFolderPath,

i already applied approved answer from AWS S3: The bucket you are attempting to access must be addressed using the specified endpoint

but still getting same error, i am using php

Code :

use Aws\S3\S3Client;
use Aws\S3\Exception\S3Exception;

class AWSS3Factory {

    private $bucket;
    private $keyname;

    public function __construct() {
        $this->bucket = AWSS3_BucketName;
        $this->keyname = AWSS3_AccessKey;
        // Instantiate the client.
    }

    public function UploadFile($FullFilePath,$PrefixFolderPath="") {
        try {
            $s3 = S3Client::factory(array(
                'credentials' => array(
                    'key'    => MYKEY,
                    'secret' => MYSECKEY,
                    'region' => 'eu-west-1',
                )
            ));

            // Upload data.
            $result = $s3->putObject(array(
                'Bucket'       => $this->bucket . "/" . $PrefixFolderPath,
                'Key'          => $this->keyname,
                'SourceFile'   => $FullFilePath,
                'StorageClass' => 'REDUCED_REDUNDANCY'
            ));
            return true;
            // Print the URL to the object.
            //echo $result['ObjectURL'] . "\n";
        } catch (S3Exception $e) {
            echo $e->getMessage() . "\n";
        }
    }
 }
over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

You must add $PrefixFolderPath not to 'Bucket' but to 'Key':

$result = $s3->putObject(array(
    'Bucket'       => $this->bucket,
    'Key'          => $PrefixFolderPath . "/" . $this->keyname,
    'SourceFile'   => $FullFilePath,
    'StorageClass' => 'REDUCED_REDUNDANCY'
));
over 4 years ago · Santiago Trujillo Denunciar

0

You must create s3 instance in another way, like this:

$s3 = S3Client::factory([
    'region'      => '',
    'credentials' => ['key' => '***', 'secret' => '***'],
    'version' => 'latest',
]);
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda