Skip to content

Commit

Permalink
Merge pull request #509 from root-gg/fix_s3_min_part_size
Browse files Browse the repository at this point in the history
fix s3 min part size
  • Loading branch information
camathieu authored Jan 2, 2024
2 parents 7d9b09e + 4eab77c commit ad65dd4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions server/data/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func NewConfig(params map[string]interface{}) (config *Config) {
config = new(Config)
config.Bucket = "plik"
config.Location = "us-east-1"
config.PartSize = 16 * 1000 * 1000 // 16MB
config.PartSize = 16 * 1024 * 1024 // 16MiB
utils.Assign(config, params)
return
}
Expand All @@ -57,7 +57,7 @@ func (config *Config) Validate() error {
if config.Location == "" {
return fmt.Errorf("missing location")
}
if config.PartSize < 5*1000*1000 {
if config.PartSize < 5*1024*1024 {
return fmt.Errorf("invalid part size")
}
return nil
Expand Down Expand Up @@ -139,9 +139,9 @@ func (b *Backend) AddFile(file *common.File, fileReader io.Reader) (err error) {
_, err = b.client.PutObject(context.TODO(), b.config.Bucket, b.getObjectName(file.ID), fileReader, file.Size, putOpts)
} else {
// https://github.com/minio/minio-go/issues/989
// Minio defaults to 128MB chunks and has to actually allocate a buffer of this size before uploading the chunk
// Minio defaults to 128MiB chunks and has to actually allocate a buffer of this size before uploading the chunk
// This can lead to very high memory usage when uploading a lot of small files in parallel
// We default to 16MB which allow to store files up to 160GB ( 10000 chunks of 16MB ), feel free to adjust this parameter to your needs.
// We default to 16MiB which allow to store files up to 156GiB ( 10000 chunks of 16MiB ), feel free to adjust this parameter to your needs.
putOpts.PartSize = b.config.PartSize

_, err = b.client.PutObject(context.TODO(), b.config.Bucket, b.getObjectName(file.ID), fileReader, -1, putOpts)
Expand Down
4 changes: 2 additions & 2 deletions server/plikd.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ OvhApiEndpoint = "" # OVH api endpoint to use. Defaults to ht
# Location = "us-east-1"
# Prefix = ""
# UseSSL = true
# PartSize = 16000000 // Chunk size when file size is not known. (default to 16MB)
# // Multiply by 10000 to get the max upload file size (max upload file size 160GB)
# PartSize = 16777216 // Chunk size when file size is not known. (default 16MiB, min 5MiB)
# // Multiply by 10000 to get the max upload file size (max upload file size 156GiB)
# SSE = "" // the following encryption methods are available :
# // - SSE-C: S3 server-side-encryption with keys managed by Plik
# // - S3: S3 server-side-encryption with keys managed by the S3 backend
Expand Down

0 comments on commit ad65dd4

Please sign in to comment.