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

104
Vistas
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);
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

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)
}
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