Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

259
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda