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

100
Visualizações
Write/Append to S3 bucket in Golang

The application I'm working on currently uses the Amazon S3 Stream Wrapper for PHP in order to write log messages to an S3 bucket and I need to port it over to Golang. Is there an equivilent to this in Go? The PutObject method overwrites all the contents and I want to just append. In PHP we are using fopen() and fwrite() to append a string to an existing bucket. I was hoping I could just do

os.OpenFile(filename, os.O_APPEND|os.O_WRONLY, 0600) 

but I get an error saying the file doesn't exist. I tried using both s3:// and the https:// link to the log file.

Here's the Amazon example for PHP:

$stream = fopen('s3://bucket/key', 'w');
fwrite($stream, 'Hello!');
fclose($stream);
about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

As @Rob mentioned, S3 doesn't support append operation https://forums.aws.amazon.com/message.jspa?messageID=540395.

The only way is download object and upload the new one using aws-sdk or minio (https://github.com/minio/minio). I suppose, PHP wrapper make the same under the hood.

The sample with minio:

s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESS-KEY-HERE", "YOUR-SECRET-KEY-HERE", true)
if err != nil {
    log.Fatalln(err)
}

reader, err := s3Client.GetObject("my-bucketname", "my-objectname")
if err != nil {
    log.Fatalln(err)
}
defer reader.Close()

// Change your data

n, err := s3Client.PutObject("my-bucketname", "my-objectname", reader, "application/octet-stream")
if err != nil {
    log.Fatalln(err)
}
about 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