Skip to content

Commit 3654b77

Browse files
FIX (backups): Stream backups to S3 instead of loading backup to RAM in start
1 parent 84cbf57 commit 3654b77

File tree

1 file changed

+3
-10
lines changed
  • backend/internal/features/storages/models/s3

1 file changed

+3
-10
lines changed

backend/internal/features/storages/models/s3/model.go

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package s3_storage
22

33
import (
4-
"bytes"
54
"context"
65
"errors"
76
"fmt"
@@ -34,19 +33,13 @@ func (s *S3Storage) SaveFile(logger *slog.Logger, fileID uuid.UUID, file io.Read
3433
return err
3534
}
3635

37-
// Read the entire file into memory
38-
data, err := io.ReadAll(file)
39-
if err != nil {
40-
return fmt.Errorf("failed to read file: %w", err)
41-
}
42-
43-
// Upload the file using MinIO client
36+
// Upload the file using MinIO client with streaming (size = -1 for unknown size)
4437
_, err = client.PutObject(
4538
context.TODO(),
4639
s.S3Bucket,
4740
fileID.String(),
48-
bytes.NewReader(data),
49-
int64(len(data)),
41+
file,
42+
-1,
5043
minio.PutObjectOptions{},
5144
)
5245
if err != nil {

0 commit comments

Comments
 (0)