cmd/dendrite-media-api-server: Add MAX_FILE_SIZE_BYTES configuration

This commit is contained in:
Robert Swain 2017-05-18 11:44:48 +02:00
parent 846aece163
commit 7727a8c61e

View file

@ -17,6 +17,7 @@ package main
import (
"net/http"
"os"
"strconv"
"github.com/matrix-org/dendrite/common"
"github.com/matrix-org/dendrite/mediaapi/config"
@ -48,11 +49,16 @@ func main() {
if serverName == "" {
serverName = "localhost"
}
maxFileSizeBytes, err := strconv.ParseInt(os.Getenv("MAX_FILE_SIZE_BYTES"), 10, 64)
if err != nil {
maxFileSizeBytes = 10 * 1024 * 1024
log.Info("Failed to parse MAX_FILE_SIZE_BYTES. Defaulting to %v bytes.", maxFileSizeBytes)
}
cfg := &config.MediaAPI{
ServerName: types.ServerName(serverName),
BasePath: types.Path(basePath),
MaxFileSizeBytes: 10 * 1024 * 1024,
MaxFileSizeBytes: types.ContentLength(maxFileSizeBytes),
DataSource: dataSource,
}