Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

98
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!