Changing image settings to file settings

Этот коммит содержится в:
=Corey Hulen
2015-09-23 13:47:10 -07:00
родитель 2b5b8f95ed
Коммит ccf2e6e4e7
15 изменённых файлов: 132 добавлений и 132 удалений

Просмотреть файл

@@ -278,11 +278,11 @@ func copyDirToExportWriter(writer ExportWriter, inPath string, outPath string) *
} }
func ExportLocalStorage(writer ExportWriter, options *ExportOptions, teamId string) *model.AppError { func ExportLocalStorage(writer ExportWriter, options *ExportOptions, teamId string) *model.AppError {
teamDir := utils.Cfg.ImageSettings.Directory + "teams/" + teamId teamDir := utils.Cfg.FileSettings.Directory + "teams/" + teamId
if utils.Cfg.ImageSettings.DriverName == model.IMAGE_DRIVER_S3 { if utils.Cfg.FileSettings.DriverName == model.IMAGE_DRIVER_S3 {
return model.NewAppError("ExportLocalStorage", "S3 is not supported for local storage export.", "") return model.NewAppError("ExportLocalStorage", "S3 is not supported for local storage export.", "")
} else if utils.Cfg.ImageSettings.DriverName == model.IMAGE_DRIVER_LOCAL { } else if utils.Cfg.FileSettings.DriverName == model.IMAGE_DRIVER_LOCAL {
if err := copyDirToExportWriter(writer, teamDir, EXPORT_LOCAL_STORAGE_FOLDER); err != nil { if err := copyDirToExportWriter(writer, teamDir, EXPORT_LOCAL_STORAGE_FOLDER); err != nil {
return err return err
} }

Просмотреть файл

@@ -69,7 +69,7 @@ func InitFile(r *mux.Router) {
} }
func uploadFile(c *Context, w http.ResponseWriter, r *http.Request) { func uploadFile(c *Context, w http.ResponseWriter, r *http.Request) {
if len(utils.Cfg.ImageSettings.DriverName) == 0 { if len(utils.Cfg.FileSettings.DriverName) == 0 {
c.Err = model.NewAppError("uploadFile", "Unable to upload file. Image storage is not configured.", "") c.Err = model.NewAppError("uploadFile", "Unable to upload file. Image storage is not configured.", "")
c.Err.StatusCode = http.StatusNotImplemented c.Err.StatusCode = http.StatusNotImplemented
return return
@@ -217,8 +217,8 @@ func fireAndForgetHandleImages(filenames []string, fileData [][]byte, teamId, ch
// Create thumbnail // Create thumbnail
go func() { go func() {
thumbWidth := float64(utils.Cfg.ImageSettings.ThumbnailWidth) thumbWidth := float64(utils.Cfg.FileSettings.ThumbnailWidth)
thumbHeight := float64(utils.Cfg.ImageSettings.ThumbnailHeight) thumbHeight := float64(utils.Cfg.FileSettings.ThumbnailHeight)
imgWidth := float64(width) imgWidth := float64(width)
imgHeight := float64(height) imgHeight := float64(height)
@@ -226,9 +226,9 @@ func fireAndForgetHandleImages(filenames []string, fileData [][]byte, teamId, ch
if imgHeight < thumbHeight && imgWidth < thumbWidth { if imgHeight < thumbHeight && imgWidth < thumbWidth {
thumbnail = img thumbnail = img
} else if imgHeight/imgWidth < thumbHeight/thumbWidth { } else if imgHeight/imgWidth < thumbHeight/thumbWidth {
thumbnail = resize.Resize(0, utils.Cfg.ImageSettings.ThumbnailHeight, img, resize.Lanczos3) thumbnail = resize.Resize(0, utils.Cfg.FileSettings.ThumbnailHeight, img, resize.Lanczos3)
} else { } else {
thumbnail = resize.Resize(utils.Cfg.ImageSettings.ThumbnailWidth, 0, img, resize.Lanczos3) thumbnail = resize.Resize(utils.Cfg.FileSettings.ThumbnailWidth, 0, img, resize.Lanczos3)
} }
buf := new(bytes.Buffer) buf := new(bytes.Buffer)
@@ -247,8 +247,8 @@ func fireAndForgetHandleImages(filenames []string, fileData [][]byte, teamId, ch
// Create preview // Create preview
go func() { go func() {
var preview image.Image var preview image.Image
if width > int(utils.Cfg.ImageSettings.PreviewWidth) { if width > int(utils.Cfg.FileSettings.PreviewWidth) {
preview = resize.Resize(utils.Cfg.ImageSettings.PreviewWidth, utils.Cfg.ImageSettings.PreviewHeight, img, resize.Lanczos3) preview = resize.Resize(utils.Cfg.FileSettings.PreviewWidth, utils.Cfg.FileSettings.PreviewHeight, img, resize.Lanczos3)
} else { } else {
preview = img preview = img
} }
@@ -294,7 +294,7 @@ type ImageGetResult struct {
} }
func getFileInfo(c *Context, w http.ResponseWriter, r *http.Request) { func getFileInfo(c *Context, w http.ResponseWriter, r *http.Request) {
if len(utils.Cfg.ImageSettings.DriverName) == 0 { if len(utils.Cfg.FileSettings.DriverName) == 0 {
c.Err = model.NewAppError("uploadFile", "Unable to get file info. Image storage is not configured.", "") c.Err = model.NewAppError("uploadFile", "Unable to get file info. Image storage is not configured.", "")
c.Err.StatusCode = http.StatusNotImplemented c.Err.StatusCode = http.StatusNotImplemented
return return
@@ -357,7 +357,7 @@ func getFileInfo(c *Context, w http.ResponseWriter, r *http.Request) {
} }
func getFile(c *Context, w http.ResponseWriter, r *http.Request) { func getFile(c *Context, w http.ResponseWriter, r *http.Request) {
if len(utils.Cfg.ImageSettings.DriverName) == 0 { if len(utils.Cfg.FileSettings.DriverName) == 0 {
c.Err = model.NewAppError("uploadFile", "Unable to get file. Image storage is not configured.", "") c.Err = model.NewAppError("uploadFile", "Unable to get file. Image storage is not configured.", "")
c.Err.StatusCode = http.StatusNotImplemented c.Err.StatusCode = http.StatusNotImplemented
return return
@@ -400,7 +400,7 @@ func getFile(c *Context, w http.ResponseWriter, r *http.Request) {
asyncGetFile(path, fileData) asyncGetFile(path, fileData)
if len(hash) > 0 && len(data) > 0 && len(teamId) == 26 { if len(hash) > 0 && len(data) > 0 && len(teamId) == 26 {
if !model.ComparePassword(hash, fmt.Sprintf("%v:%v", data, utils.Cfg.ImageSettings.PublicLinkSalt)) { if !model.ComparePassword(hash, fmt.Sprintf("%v:%v", data, utils.Cfg.FileSettings.PublicLinkSalt)) {
c.Err = model.NewAppError("getFile", "The public link does not appear to be valid", "") c.Err = model.NewAppError("getFile", "The public link does not appear to be valid", "")
return return
} }
@@ -442,13 +442,13 @@ func asyncGetFile(path string, fileData chan []byte) {
} }
func getPublicLink(c *Context, w http.ResponseWriter, r *http.Request) { func getPublicLink(c *Context, w http.ResponseWriter, r *http.Request) {
if len(utils.Cfg.ImageSettings.DriverName) == 0 { if len(utils.Cfg.FileSettings.DriverName) == 0 {
c.Err = model.NewAppError("uploadFile", "Unable to get link. Image storage is not configured.", "") c.Err = model.NewAppError("uploadFile", "Unable to get link. Image storage is not configured.", "")
c.Err.StatusCode = http.StatusNotImplemented c.Err.StatusCode = http.StatusNotImplemented
return return
} }
if !utils.Cfg.ImageSettings.EnablePublicLink { if !utils.Cfg.FileSettings.EnablePublicLink {
c.Err = model.NewAppError("getPublicLink", "Public links have been disabled", "") c.Err = model.NewAppError("getPublicLink", "Public links have been disabled", "")
c.Err.StatusCode = http.StatusForbidden c.Err.StatusCode = http.StatusForbidden
} }
@@ -478,7 +478,7 @@ func getPublicLink(c *Context, w http.ResponseWriter, r *http.Request) {
newProps["time"] = fmt.Sprintf("%v", model.GetMillis()) newProps["time"] = fmt.Sprintf("%v", model.GetMillis())
data := model.MapToJson(newProps) data := model.MapToJson(newProps)
hash := model.HashPassword(fmt.Sprintf("%v:%v", data, utils.Cfg.ImageSettings.PublicLinkSalt)) hash := model.HashPassword(fmt.Sprintf("%v:%v", data, utils.Cfg.FileSettings.PublicLinkSalt))
url := fmt.Sprintf("%s/api/v1/files/get/%s/%s/%s?d=%s&h=%s&t=%s", c.GetSiteURL(), channelId, userId, filename, url.QueryEscape(data), url.QueryEscape(hash), c.Session.TeamId) url := fmt.Sprintf("%s/api/v1/files/get/%s/%s/%s?d=%s&h=%s&t=%s", c.GetSiteURL(), channelId, userId, filename, url.QueryEscape(data), url.QueryEscape(hash), c.Session.TeamId)
@@ -511,13 +511,13 @@ func getExport(c *Context, w http.ResponseWriter, r *http.Request) {
func writeFile(f []byte, path string) *model.AppError { func writeFile(f []byte, path string) *model.AppError {
if utils.Cfg.ImageSettings.DriverName == model.IMAGE_DRIVER_S3 { if utils.Cfg.FileSettings.DriverName == model.IMAGE_DRIVER_S3 {
var auth aws.Auth var auth aws.Auth
auth.AccessKey = utils.Cfg.ImageSettings.AmazonS3AccessKeyId auth.AccessKey = utils.Cfg.FileSettings.AmazonS3AccessKeyId
auth.SecretKey = utils.Cfg.ImageSettings.AmazonS3SecretAccessKey auth.SecretKey = utils.Cfg.FileSettings.AmazonS3SecretAccessKey
s := s3.New(auth, aws.Regions[utils.Cfg.ImageSettings.AmazonS3Region]) s := s3.New(auth, aws.Regions[utils.Cfg.FileSettings.AmazonS3Region])
bucket := s.Bucket(utils.Cfg.ImageSettings.AmazonS3Bucket) bucket := s.Bucket(utils.Cfg.FileSettings.AmazonS3Bucket)
ext := filepath.Ext(path) ext := filepath.Ext(path)
@@ -534,12 +534,12 @@ func writeFile(f []byte, path string) *model.AppError {
if err != nil { if err != nil {
return model.NewAppError("writeFile", "Encountered an error writing to S3", err.Error()) return model.NewAppError("writeFile", "Encountered an error writing to S3", err.Error())
} }
} else if utils.Cfg.ImageSettings.DriverName == model.IMAGE_DRIVER_LOCAL { } else if utils.Cfg.FileSettings.DriverName == model.IMAGE_DRIVER_LOCAL {
if err := os.MkdirAll(filepath.Dir(utils.Cfg.ImageSettings.Directory+path), 0774); err != nil { if err := os.MkdirAll(filepath.Dir(utils.Cfg.FileSettings.Directory+path), 0774); err != nil {
return model.NewAppError("writeFile", "Encountered an error creating the directory for the new file", err.Error()) return model.NewAppError("writeFile", "Encountered an error creating the directory for the new file", err.Error())
} }
if err := ioutil.WriteFile(utils.Cfg.ImageSettings.Directory+path, f, 0644); err != nil { if err := ioutil.WriteFile(utils.Cfg.FileSettings.Directory+path, f, 0644); err != nil {
return model.NewAppError("writeFile", "Encountered an error writing to local server storage", err.Error()) return model.NewAppError("writeFile", "Encountered an error writing to local server storage", err.Error())
} }
} else { } else {
@@ -551,13 +551,13 @@ func writeFile(f []byte, path string) *model.AppError {
func readFile(path string) ([]byte, *model.AppError) { func readFile(path string) ([]byte, *model.AppError) {
if utils.Cfg.ImageSettings.DriverName == model.IMAGE_DRIVER_S3 { if utils.Cfg.FileSettings.DriverName == model.IMAGE_DRIVER_S3 {
var auth aws.Auth var auth aws.Auth
auth.AccessKey = utils.Cfg.ImageSettings.AmazonS3AccessKeyId auth.AccessKey = utils.Cfg.FileSettings.AmazonS3AccessKeyId
auth.SecretKey = utils.Cfg.ImageSettings.AmazonS3SecretAccessKey auth.SecretKey = utils.Cfg.FileSettings.AmazonS3SecretAccessKey
s := s3.New(auth, aws.Regions[utils.Cfg.ImageSettings.AmazonS3Region]) s := s3.New(auth, aws.Regions[utils.Cfg.FileSettings.AmazonS3Region])
bucket := s.Bucket(utils.Cfg.ImageSettings.AmazonS3Bucket) bucket := s.Bucket(utils.Cfg.FileSettings.AmazonS3Bucket)
// try to get the file from S3 with some basic retry logic // try to get the file from S3 with some basic retry logic
tries := 0 tries := 0
@@ -573,8 +573,8 @@ func readFile(path string) ([]byte, *model.AppError) {
} }
time.Sleep(3000 * time.Millisecond) time.Sleep(3000 * time.Millisecond)
} }
} else if utils.Cfg.ImageSettings.DriverName == model.IMAGE_DRIVER_LOCAL { } else if utils.Cfg.FileSettings.DriverName == model.IMAGE_DRIVER_LOCAL {
if f, err := ioutil.ReadFile(utils.Cfg.ImageSettings.Directory + path); err != nil { if f, err := ioutil.ReadFile(utils.Cfg.FileSettings.Directory + path); err != nil {
return nil, model.NewAppError("readFile", "Encountered an error reading from local server storage", err.Error()) return nil, model.NewAppError("readFile", "Encountered an error reading from local server storage", err.Error())
} else { } else {
return f, nil return f, nil
@@ -585,14 +585,14 @@ func readFile(path string) ([]byte, *model.AppError) {
} }
func openFileWriteStream(path string) (io.Writer, *model.AppError) { func openFileWriteStream(path string) (io.Writer, *model.AppError) {
if utils.Cfg.ImageSettings.DriverName == model.IMAGE_DRIVER_S3 { if utils.Cfg.FileSettings.DriverName == model.IMAGE_DRIVER_S3 {
return nil, model.NewAppError("openFileWriteStream", "S3 is not supported.", "") return nil, model.NewAppError("openFileWriteStream", "S3 is not supported.", "")
} else if utils.Cfg.ImageSettings.DriverName == model.IMAGE_DRIVER_LOCAL { } else if utils.Cfg.FileSettings.DriverName == model.IMAGE_DRIVER_LOCAL {
if err := os.MkdirAll(filepath.Dir(utils.Cfg.ImageSettings.Directory+path), 0774); err != nil { if err := os.MkdirAll(filepath.Dir(utils.Cfg.FileSettings.Directory+path), 0774); err != nil {
return nil, model.NewAppError("openFileWriteStream", "Encountered an error creating the directory for the new file", err.Error()) return nil, model.NewAppError("openFileWriteStream", "Encountered an error creating the directory for the new file", err.Error())
} }
if fileHandle, err := os.Create(utils.Cfg.ImageSettings.Directory + path); err != nil { if fileHandle, err := os.Create(utils.Cfg.FileSettings.Directory + path); err != nil {
return nil, model.NewAppError("openFileWriteStream", "Encountered an error writing to local server storage", err.Error()) return nil, model.NewAppError("openFileWriteStream", "Encountered an error writing to local server storage", err.Error())
} else { } else {
fileHandle.Chmod(0644) fileHandle.Chmod(0644)

Просмотреть файл

@@ -38,7 +38,7 @@ func BenchmarkGetFile(b *testing.B) {
newProps["time"] = fmt.Sprintf("%v", model.GetMillis()) newProps["time"] = fmt.Sprintf("%v", model.GetMillis())
data := model.MapToJson(newProps) data := model.MapToJson(newProps)
hash := model.HashPassword(fmt.Sprintf("%v:%v", data, utils.Cfg.ImageSettings.PublicLinkSalt)) hash := model.HashPassword(fmt.Sprintf("%v:%v", data, utils.Cfg.FileSettings.PublicLinkSalt))
// wait a bit for files to ready // wait a bit for files to ready
time.Sleep(5 * time.Second) time.Sleep(5 * time.Second)

Просмотреть файл

@@ -68,7 +68,7 @@ func TestUploadFile(t *testing.T) {
} }
resp, appErr := Client.UploadFile("/files/upload", body.Bytes(), writer.FormDataContentType()) resp, appErr := Client.UploadFile("/files/upload", body.Bytes(), writer.FormDataContentType())
if utils.Cfg.ImageSettings.DriverName == model.IMAGE_DRIVER_S3 { if utils.Cfg.FileSettings.DriverName == model.IMAGE_DRIVER_S3 {
if appErr != nil { if appErr != nil {
t.Fatal(appErr) t.Fatal(appErr)
} }
@@ -81,11 +81,11 @@ func TestUploadFile(t *testing.T) {
fileId := strings.Split(filename, ".")[0] fileId := strings.Split(filename, ".")[0]
var auth aws.Auth var auth aws.Auth
auth.AccessKey = utils.Cfg.ImageSettings.AmazonS3AccessKeyId auth.AccessKey = utils.Cfg.FileSettings.AmazonS3AccessKeyId
auth.SecretKey = utils.Cfg.ImageSettings.AmazonS3SecretAccessKey auth.SecretKey = utils.Cfg.FileSettings.AmazonS3SecretAccessKey
s := s3.New(auth, aws.Regions[utils.Cfg.ImageSettings.AmazonS3Region]) s := s3.New(auth, aws.Regions[utils.Cfg.FileSettings.AmazonS3Region])
bucket := s.Bucket(utils.Cfg.ImageSettings.AmazonS3Bucket) bucket := s.Bucket(utils.Cfg.FileSettings.AmazonS3Bucket)
// wait a bit for files to ready // wait a bit for files to ready
time.Sleep(5 * time.Second) time.Sleep(5 * time.Second)
@@ -104,7 +104,7 @@ func TestUploadFile(t *testing.T) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
} else if utils.Cfg.ImageSettings.DriverName == model.IMAGE_DRIVER_LOCAL { } else if utils.Cfg.FileSettings.DriverName == model.IMAGE_DRIVER_LOCAL {
filenames := strings.Split(resp.Data.(*model.FileUploadResponse).Filenames[0], "/") filenames := strings.Split(resp.Data.(*model.FileUploadResponse).Filenames[0], "/")
filename := filenames[len(filenames)-2] + "/" + filenames[len(filenames)-1] filename := filenames[len(filenames)-2] + "/" + filenames[len(filenames)-1]
if strings.Contains(filename, "../") { if strings.Contains(filename, "../") {
@@ -115,17 +115,17 @@ func TestUploadFile(t *testing.T) {
// wait a bit for files to ready // wait a bit for files to ready
time.Sleep(5 * time.Second) time.Sleep(5 * time.Second)
path := utils.Cfg.ImageSettings.Directory + "teams/" + team.Id + "/channels/" + channel1.Id + "/users/" + user1.Id + "/" + filename path := utils.Cfg.FileSettings.Directory + "teams/" + team.Id + "/channels/" + channel1.Id + "/users/" + user1.Id + "/" + filename
if err := os.Remove(path); err != nil { if err := os.Remove(path); err != nil {
t.Fatal("Couldn't remove file at " + path) t.Fatal("Couldn't remove file at " + path)
} }
path = utils.Cfg.ImageSettings.Directory + "teams/" + team.Id + "/channels/" + channel1.Id + "/users/" + user1.Id + "/" + fileId + "_thumb.jpg" path = utils.Cfg.FileSettings.Directory + "teams/" + team.Id + "/channels/" + channel1.Id + "/users/" + user1.Id + "/" + fileId + "_thumb.jpg"
if err := os.Remove(path); err != nil { if err := os.Remove(path); err != nil {
t.Fatal("Couldn't remove file at " + path) t.Fatal("Couldn't remove file at " + path)
} }
path = utils.Cfg.ImageSettings.Directory + "teams/" + team.Id + "/channels/" + channel1.Id + "/users/" + user1.Id + "/" + fileId + "_preview.jpg" path = utils.Cfg.FileSettings.Directory + "teams/" + team.Id + "/channels/" + channel1.Id + "/users/" + user1.Id + "/" + fileId + "_preview.jpg"
if err := os.Remove(path); err != nil { if err := os.Remove(path); err != nil {
t.Fatal("Couldn't remove file at " + path) t.Fatal("Couldn't remove file at " + path)
} }
@@ -151,7 +151,7 @@ func TestGetFile(t *testing.T) {
channel1 := &model.Channel{DisplayName: "Test API Name", Name: "a" + model.NewId() + "a", Type: model.CHANNEL_OPEN, TeamId: team.Id} channel1 := &model.Channel{DisplayName: "Test API Name", Name: "a" + model.NewId() + "a", Type: model.CHANNEL_OPEN, TeamId: team.Id}
channel1 = Client.Must(Client.CreateChannel(channel1)).Data.(*model.Channel) channel1 = Client.Must(Client.CreateChannel(channel1)).Data.(*model.Channel)
if utils.Cfg.ImageSettings.DriverName != "" { if utils.Cfg.FileSettings.DriverName != "" {
body := &bytes.Buffer{} body := &bytes.Buffer{}
writer := multipart.NewWriter(body) writer := multipart.NewWriter(body)
@@ -222,7 +222,7 @@ func TestGetFile(t *testing.T) {
newProps["time"] = fmt.Sprintf("%v", model.GetMillis()) newProps["time"] = fmt.Sprintf("%v", model.GetMillis())
data := model.MapToJson(newProps) data := model.MapToJson(newProps)
hash := model.HashPassword(fmt.Sprintf("%v:%v", data, utils.Cfg.ImageSettings.PublicLinkSalt)) hash := model.HashPassword(fmt.Sprintf("%v:%v", data, utils.Cfg.FileSettings.PublicLinkSalt))
Client.LoginByEmail(team2.Name, user2.Email, "pwd") Client.LoginByEmail(team2.Name, user2.Email, "pwd")
@@ -262,13 +262,13 @@ func TestGetFile(t *testing.T) {
t.Fatal("Should have errored - user not logged in and link not public") t.Fatal("Should have errored - user not logged in and link not public")
} }
if utils.Cfg.ImageSettings.DriverName == model.IMAGE_DRIVER_S3 { if utils.Cfg.FileSettings.DriverName == model.IMAGE_DRIVER_S3 {
var auth aws.Auth var auth aws.Auth
auth.AccessKey = utils.Cfg.ImageSettings.AmazonS3AccessKeyId auth.AccessKey = utils.Cfg.FileSettings.AmazonS3AccessKeyId
auth.SecretKey = utils.Cfg.ImageSettings.AmazonS3SecretAccessKey auth.SecretKey = utils.Cfg.FileSettings.AmazonS3SecretAccessKey
s := s3.New(auth, aws.Regions[utils.Cfg.ImageSettings.AmazonS3Region]) s := s3.New(auth, aws.Regions[utils.Cfg.FileSettings.AmazonS3Region])
bucket := s.Bucket(utils.Cfg.ImageSettings.AmazonS3Bucket) bucket := s.Bucket(utils.Cfg.FileSettings.AmazonS3Bucket)
filenames := strings.Split(resp.Data.(*model.FileUploadResponse).Filenames[0], "/") filenames := strings.Split(resp.Data.(*model.FileUploadResponse).Filenames[0], "/")
filename := filenames[len(filenames)-2] + "/" + filenames[len(filenames)-1] filename := filenames[len(filenames)-2] + "/" + filenames[len(filenames)-1]
@@ -293,17 +293,17 @@ func TestGetFile(t *testing.T) {
filename := filenames[len(filenames)-2] + "/" + filenames[len(filenames)-1] filename := filenames[len(filenames)-2] + "/" + filenames[len(filenames)-1]
fileId := strings.Split(filename, ".")[0] fileId := strings.Split(filename, ".")[0]
path := utils.Cfg.ImageSettings.Directory + "teams/" + team.Id + "/channels/" + channel1.Id + "/users/" + user1.Id + "/" + filename path := utils.Cfg.FileSettings.Directory + "teams/" + team.Id + "/channels/" + channel1.Id + "/users/" + user1.Id + "/" + filename
if err := os.Remove(path); err != nil { if err := os.Remove(path); err != nil {
t.Fatal("Couldn't remove file at " + path) t.Fatal("Couldn't remove file at " + path)
} }
path = utils.Cfg.ImageSettings.Directory + "teams/" + team.Id + "/channels/" + channel1.Id + "/users/" + user1.Id + "/" + fileId + "_thumb.jpg" path = utils.Cfg.FileSettings.Directory + "teams/" + team.Id + "/channels/" + channel1.Id + "/users/" + user1.Id + "/" + fileId + "_thumb.jpg"
if err := os.Remove(path); err != nil { if err := os.Remove(path); err != nil {
t.Fatal("Couldn't remove file at " + path) t.Fatal("Couldn't remove file at " + path)
} }
path = utils.Cfg.ImageSettings.Directory + "teams/" + team.Id + "/channels/" + channel1.Id + "/users/" + user1.Id + "/" + fileId + "_preview.jpg" path = utils.Cfg.FileSettings.Directory + "teams/" + team.Id + "/channels/" + channel1.Id + "/users/" + user1.Id + "/" + fileId + "_preview.jpg"
if err := os.Remove(path); err != nil { if err := os.Remove(path); err != nil {
t.Fatal("Couldn't remove file at " + path) t.Fatal("Couldn't remove file at " + path)
} }
@@ -334,7 +334,7 @@ func TestGetPublicLink(t *testing.T) {
channel1 := &model.Channel{DisplayName: "Test API Name", Name: "a" + model.NewId() + "a", Type: model.CHANNEL_OPEN, TeamId: team.Id} channel1 := &model.Channel{DisplayName: "Test API Name", Name: "a" + model.NewId() + "a", Type: model.CHANNEL_OPEN, TeamId: team.Id}
channel1 = Client.Must(Client.CreateChannel(channel1)).Data.(*model.Channel) channel1 = Client.Must(Client.CreateChannel(channel1)).Data.(*model.Channel)
if utils.Cfg.ImageSettings.DriverName != "" { if utils.Cfg.FileSettings.DriverName != "" {
body := &bytes.Buffer{} body := &bytes.Buffer{}
writer := multipart.NewWriter(body) writer := multipart.NewWriter(body)
@@ -410,14 +410,14 @@ func TestGetPublicLink(t *testing.T) {
t.Fatal("should have errored, user not member of channel") t.Fatal("should have errored, user not member of channel")
} }
if utils.Cfg.ImageSettings.DriverName == model.IMAGE_DRIVER_S3 { if utils.Cfg.FileSettings.DriverName == model.IMAGE_DRIVER_S3 {
// perform clean-up on s3 // perform clean-up on s3
var auth aws.Auth var auth aws.Auth
auth.AccessKey = utils.Cfg.ImageSettings.AmazonS3AccessKeyId auth.AccessKey = utils.Cfg.FileSettings.AmazonS3AccessKeyId
auth.SecretKey = utils.Cfg.ImageSettings.AmazonS3SecretAccessKey auth.SecretKey = utils.Cfg.FileSettings.AmazonS3SecretAccessKey
s := s3.New(auth, aws.Regions[utils.Cfg.ImageSettings.AmazonS3Region]) s := s3.New(auth, aws.Regions[utils.Cfg.FileSettings.AmazonS3Region])
bucket := s.Bucket(utils.Cfg.ImageSettings.AmazonS3Bucket) bucket := s.Bucket(utils.Cfg.FileSettings.AmazonS3Bucket)
filenames := strings.Split(resp.Data.(*model.FileUploadResponse).Filenames[0], "/") filenames := strings.Split(resp.Data.(*model.FileUploadResponse).Filenames[0], "/")
filename := filenames[len(filenames)-2] + "/" + filenames[len(filenames)-1] filename := filenames[len(filenames)-2] + "/" + filenames[len(filenames)-1]
@@ -442,17 +442,17 @@ func TestGetPublicLink(t *testing.T) {
filename := filenames[len(filenames)-2] + "/" + filenames[len(filenames)-1] filename := filenames[len(filenames)-2] + "/" + filenames[len(filenames)-1]
fileId := strings.Split(filename, ".")[0] fileId := strings.Split(filename, ".")[0]
path := utils.Cfg.ImageSettings.Directory + "teams/" + team.Id + "/channels/" + channel1.Id + "/users/" + user1.Id + "/" + filename path := utils.Cfg.FileSettings.Directory + "teams/" + team.Id + "/channels/" + channel1.Id + "/users/" + user1.Id + "/" + filename
if err := os.Remove(path); err != nil { if err := os.Remove(path); err != nil {
t.Fatal("Couldn't remove file at " + path) t.Fatal("Couldn't remove file at " + path)
} }
path = utils.Cfg.ImageSettings.Directory + "teams/" + team.Id + "/channels/" + channel1.Id + "/users/" + user1.Id + "/" + fileId + "_thumb.jpg" path = utils.Cfg.FileSettings.Directory + "teams/" + team.Id + "/channels/" + channel1.Id + "/users/" + user1.Id + "/" + fileId + "_thumb.jpg"
if err := os.Remove(path); err != nil { if err := os.Remove(path); err != nil {
t.Fatal("Couldn't remove file at " + path) t.Fatal("Couldn't remove file at " + path)
} }
path = utils.Cfg.ImageSettings.Directory + "teams/" + team.Id + "/channels/" + channel1.Id + "/users/" + user1.Id + "/" + fileId + "_preview.jpg" path = utils.Cfg.FileSettings.Directory + "teams/" + team.Id + "/channels/" + channel1.Id + "/users/" + user1.Id + "/" + fileId + "_preview.jpg"
if err := os.Remove(path); err != nil { if err := os.Remove(path); err != nil {
t.Fatal("Couldn't remove file at " + path) t.Fatal("Couldn't remove file at " + path)
} }

Просмотреть файл

@@ -646,7 +646,7 @@ func createProfileImage(username string, userId string) ([]byte, *model.AppError
initial := string(strings.ToUpper(username)[0]) initial := string(strings.ToUpper(username)[0])
fontBytes, err := ioutil.ReadFile(utils.FindDir("web/static/fonts") + utils.Cfg.ImageSettings.InitialFont) fontBytes, err := ioutil.ReadFile(utils.FindDir("web/static/fonts") + utils.Cfg.FileSettings.InitialFont)
if err != nil { if err != nil {
return nil, model.NewAppError("createProfileImage", "Could not create default profile image font", err.Error()) return nil, model.NewAppError("createProfileImage", "Could not create default profile image font", err.Error())
} }
@@ -655,8 +655,8 @@ func createProfileImage(username string, userId string) ([]byte, *model.AppError
return nil, model.NewAppError("createProfileImage", "Could not create default profile image font", err.Error()) return nil, model.NewAppError("createProfileImage", "Could not create default profile image font", err.Error())
} }
width := int(utils.Cfg.ImageSettings.ProfileWidth) width := int(utils.Cfg.FileSettings.ProfileWidth)
height := int(utils.Cfg.ImageSettings.ProfileHeight) height := int(utils.Cfg.FileSettings.ProfileHeight)
color := colors[int64(seed)%int64(len(colors))] color := colors[int64(seed)%int64(len(colors))]
dstImg := image.NewRGBA(image.Rect(0, 0, width, height)) dstImg := image.NewRGBA(image.Rect(0, 0, width, height))
srcImg := image.White srcImg := image.White
@@ -695,7 +695,7 @@ func getProfileImage(c *Context, w http.ResponseWriter, r *http.Request) {
} else { } else {
var img []byte var img []byte
if len(utils.Cfg.ImageSettings.DriverName) == 0 { if len(utils.Cfg.FileSettings.DriverName) == 0 {
var err *model.AppError var err *model.AppError
if img, err = createProfileImage(result.Data.(*model.User).Username, id); err != nil { if img, err = createProfileImage(result.Data.(*model.User).Username, id); err != nil {
c.Err = err c.Err = err
@@ -732,7 +732,7 @@ func getProfileImage(c *Context, w http.ResponseWriter, r *http.Request) {
} }
func uploadProfileImage(c *Context, w http.ResponseWriter, r *http.Request) { func uploadProfileImage(c *Context, w http.ResponseWriter, r *http.Request) {
if len(utils.Cfg.ImageSettings.DriverName) == 0 { if len(utils.Cfg.FileSettings.DriverName) == 0 {
c.Err = model.NewAppError("uploadProfileImage", "Unable to upload file. Image storage is not configured.", "") c.Err = model.NewAppError("uploadProfileImage", "Unable to upload file. Image storage is not configured.", "")
c.Err.StatusCode = http.StatusNotImplemented c.Err.StatusCode = http.StatusNotImplemented
return return
@@ -775,7 +775,7 @@ func uploadProfileImage(c *Context, w http.ResponseWriter, r *http.Request) {
} }
// Scale profile image // Scale profile image
img = resize.Resize(utils.Cfg.ImageSettings.ProfileWidth, utils.Cfg.ImageSettings.ProfileHeight, img, resize.Lanczos3) img = resize.Resize(utils.Cfg.FileSettings.ProfileWidth, utils.Cfg.FileSettings.ProfileHeight, img, resize.Lanczos3)
buf := new(bytes.Buffer) buf := new(bytes.Buffer)
err = png.Encode(buf, img) err = png.Encode(buf, img)

Просмотреть файл

@@ -352,19 +352,19 @@ func TestUserCreateImage(t *testing.T) {
Client.DoApiGet("/users/"+user.Id+"/image", "", "") Client.DoApiGet("/users/"+user.Id+"/image", "", "")
if utils.Cfg.ImageSettings.DriverName == model.IMAGE_DRIVER_S3 { if utils.Cfg.FileSettings.DriverName == model.IMAGE_DRIVER_S3 {
var auth aws.Auth var auth aws.Auth
auth.AccessKey = utils.Cfg.ImageSettings.AmazonS3AccessKeyId auth.AccessKey = utils.Cfg.FileSettings.AmazonS3AccessKeyId
auth.SecretKey = utils.Cfg.ImageSettings.AmazonS3SecretAccessKey auth.SecretKey = utils.Cfg.FileSettings.AmazonS3SecretAccessKey
s := s3.New(auth, aws.Regions[utils.Cfg.ImageSettings.AmazonS3Region]) s := s3.New(auth, aws.Regions[utils.Cfg.FileSettings.AmazonS3Region])
bucket := s.Bucket(utils.Cfg.ImageSettings.AmazonS3Bucket) bucket := s.Bucket(utils.Cfg.FileSettings.AmazonS3Bucket)
if err := bucket.Del("teams/" + user.TeamId + "/users/" + user.Id + "/profile.png"); err != nil { if err := bucket.Del("teams/" + user.TeamId + "/users/" + user.Id + "/profile.png"); err != nil {
t.Fatal(err) t.Fatal(err)
} }
} else { } else {
path := utils.Cfg.ImageSettings.Directory + "teams/" + user.TeamId + "/users/" + user.Id + "/profile.png" path := utils.Cfg.FileSettings.Directory + "teams/" + user.TeamId + "/users/" + user.Id + "/profile.png"
if err := os.Remove(path); err != nil { if err := os.Remove(path); err != nil {
t.Fatal("Couldn't remove file at " + path) t.Fatal("Couldn't remove file at " + path)
} }
@@ -382,7 +382,7 @@ func TestUserUploadProfileImage(t *testing.T) {
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
store.Must(Srv.Store.User().VerifyEmail(user.Id)) store.Must(Srv.Store.User().VerifyEmail(user.Id))
if utils.Cfg.ImageSettings.DriverName != "" { if utils.Cfg.FileSettings.DriverName != "" {
body := &bytes.Buffer{} body := &bytes.Buffer{}
writer := multipart.NewWriter(body) writer := multipart.NewWriter(body)
@@ -450,19 +450,19 @@ func TestUserUploadProfileImage(t *testing.T) {
Client.DoApiGet("/users/"+user.Id+"/image", "", "") Client.DoApiGet("/users/"+user.Id+"/image", "", "")
if utils.Cfg.ImageSettings.DriverName == model.IMAGE_DRIVER_S3 { if utils.Cfg.FileSettings.DriverName == model.IMAGE_DRIVER_S3 {
var auth aws.Auth var auth aws.Auth
auth.AccessKey = utils.Cfg.ImageSettings.AmazonS3AccessKeyId auth.AccessKey = utils.Cfg.FileSettings.AmazonS3AccessKeyId
auth.SecretKey = utils.Cfg.ImageSettings.AmazonS3SecretAccessKey auth.SecretKey = utils.Cfg.FileSettings.AmazonS3SecretAccessKey
s := s3.New(auth, aws.Regions[utils.Cfg.ImageSettings.AmazonS3Region]) s := s3.New(auth, aws.Regions[utils.Cfg.FileSettings.AmazonS3Region])
bucket := s.Bucket(utils.Cfg.ImageSettings.AmazonS3Bucket) bucket := s.Bucket(utils.Cfg.FileSettings.AmazonS3Bucket)
if err := bucket.Del("teams/" + user.TeamId + "/users/" + user.Id + "/profile.png"); err != nil { if err := bucket.Del("teams/" + user.TeamId + "/users/" + user.Id + "/profile.png"); err != nil {
t.Fatal(err) t.Fatal(err)
} }
} else { } else {
path := utils.Cfg.ImageSettings.Directory + "teams/" + user.TeamId + "/users/" + user.Id + "/profile.png" path := utils.Cfg.FileSettings.Directory + "teams/" + user.TeamId + "/users/" + user.Id + "/profile.png"
if err := os.Remove(path); err != nil { if err := os.Remove(path); err != nil {
t.Fatal("Couldn't remove file at " + path) t.Fatal("Couldn't remove file at " + path)
} }

Просмотреть файл

@@ -33,11 +33,11 @@
"FileFormat": "", "FileFormat": "",
"FileLocation": "" "FileLocation": ""
}, },
"ImageSettings": { "FileSettings": {
"DriverName": "local", "DriverName": "local",
"Directory": "./data/", "Directory": "./data/",
"EnablePublicLink": true, "EnablePublicLink": true,
"PublicLinkSalt": "LhaAWC6lYEKHTkBKsvyXNIOfUIT37AXe", "PublicLinkSalt": "A705AklYF8MFDOfcwh3I488G8vtLlVip",
"ThumbnailWidth": 120, "ThumbnailWidth": 120,
"ThumbnailHeight": 100, "ThumbnailHeight": 100,
"PreviewWidth": 1024, "PreviewWidth": 1024,

Просмотреть файл

@@ -33,7 +33,7 @@
"FileFormat": "", "FileFormat": "",
"FileLocation": "" "FileLocation": ""
}, },
"ImageSettings": { "FileSettings": {
"DriverName": "local", "DriverName": "local",
"Directory": "/mattermost/data/", "Directory": "/mattermost/data/",
"EnablePublicLink": true, "EnablePublicLink": true,

Просмотреть файл

@@ -33,7 +33,7 @@
"FileFormat": "", "FileFormat": "",
"FileLocation": "" "FileLocation": ""
}, },
"ImageSettings": { "FileSettings": {
"DriverName": "local", "DriverName": "local",
"Directory": "/mattermost/data/", "Directory": "/mattermost/data/",
"EnablePublicLink": true, "EnablePublicLink": true,

Просмотреть файл

@@ -58,7 +58,7 @@ type LogSettings struct {
FileLocation string FileLocation string
} }
type ImageSettings struct { type FileSettings struct {
DriverName string DriverName string
Directory string Directory string
EnablePublicLink bool EnablePublicLink bool
@@ -123,7 +123,7 @@ type Config struct {
TeamSettings TeamSettings TeamSettings TeamSettings
SqlSettings SqlSettings SqlSettings SqlSettings
LogSettings LogSettings LogSettings LogSettings
ImageSettings ImageSettings FileSettings FileSettings
EmailSettings EmailSettings EmailSettings EmailSettings
RateLimitSettings RateLimitSettings RateLimitSettings RateLimitSettings
PrivacySettings PrivacySettings PrivacySettings PrivacySettings

Просмотреть файл

@@ -188,9 +188,9 @@ func getClientProperties(c *model.Config) map[string]string {
props["ShowEmailAddress"] = strconv.FormatBool(c.PrivacySettings.ShowEmailAddress) props["ShowEmailAddress"] = strconv.FormatBool(c.PrivacySettings.ShowEmailAddress)
props["EnablePublicLink"] = strconv.FormatBool(c.ImageSettings.EnablePublicLink) props["EnablePublicLink"] = strconv.FormatBool(c.FileSettings.EnablePublicLink)
props["ProfileHeight"] = fmt.Sprintf("%v", c.ImageSettings.ProfileHeight) props["ProfileHeight"] = fmt.Sprintf("%v", c.FileSettings.ProfileHeight)
props["ProfileWidth"] = fmt.Sprintf("%v", c.ImageSettings.ProfileWidth) props["ProfileWidth"] = fmt.Sprintf("%v", c.FileSettings.ProfileWidth)
return props return props
} }

Просмотреть файл

@@ -9,7 +9,7 @@ var LoadingScreen = require('../loading_screen.jsx');
var EmailSettingsTab = require('./email_settings.jsx'); var EmailSettingsTab = require('./email_settings.jsx');
var LogSettingsTab = require('./log_settings.jsx'); var LogSettingsTab = require('./log_settings.jsx');
var LogsTab = require('./logs.jsx'); var LogsTab = require('./logs.jsx');
var ImageSettingsTab = require('./image_settings.jsx'); var FileSettingsTab = require('./image_settings.jsx');
var PrivacySettingsTab = require('./privacy_settings.jsx'); var PrivacySettingsTab = require('./privacy_settings.jsx');
var RateSettingsTab = require('./rate_settings.jsx'); var RateSettingsTab = require('./rate_settings.jsx');
var GitLabSettingsTab = require('./gitlab_settings.jsx'); var GitLabSettingsTab = require('./gitlab_settings.jsx');
@@ -61,7 +61,7 @@ export default class AdminController extends React.Component {
} else if (this.state.selected === 'logs') { } else if (this.state.selected === 'logs') {
tab = <LogsTab />; tab = <LogsTab />;
} else if (this.state.selected === 'image_settings') { } else if (this.state.selected === 'image_settings') {
tab = <ImageSettingsTab config={this.state.config} />; tab = <FileSettingsTab config={this.state.config} />;
} else if (this.state.selected === 'privacy_settings') { } else if (this.state.selected === 'privacy_settings') {
tab = <PrivacySettingsTab config={this.state.config} />; tab = <PrivacySettingsTab config={this.state.config} />;
} else if (this.state.selected === 'rate_settings') { } else if (this.state.selected === 'rate_settings') {

Просмотреть файл

@@ -80,7 +80,7 @@ export default class AdminSidebar extends React.Component {
className={this.isSelected('image_settings')} className={this.isSelected('image_settings')}
onClick={this.handleClick.bind(this, 'image_settings')} onClick={this.handleClick.bind(this, 'image_settings')}
> >
{'Image Settings'} {'File Settings'}
</a> </a>
</li> </li>
<li> <li>

Просмотреть файл

@@ -5,7 +5,7 @@ var Client = require('../../utils/client.jsx');
var AsyncClient = require('../../utils/async_client.jsx'); var AsyncClient = require('../../utils/async_client.jsx');
var crypto = require('crypto'); var crypto = require('crypto');
export default class ImageSettings extends React.Component { export default class FileSettings extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
@@ -16,7 +16,7 @@ export default class ImageSettings extends React.Component {
this.state = { this.state = {
saveNeeded: false, saveNeeded: false,
serverError: null, serverError: null,
DriverName: this.props.config.ImageSettings.DriverName DriverName: this.props.config.FileSettings.DriverName
}; };
} }
@@ -42,61 +42,61 @@ export default class ImageSettings extends React.Component {
$('#save-button').button('loading'); $('#save-button').button('loading');
var config = this.props.config; var config = this.props.config;
config.ImageSettings.DriverName = React.findDOMNode(this.refs.DriverName).value; config.FileSettings.DriverName = React.findDOMNode(this.refs.DriverName).value;
config.ImageSettings.Directory = React.findDOMNode(this.refs.Directory).value; config.FileSettings.Directory = React.findDOMNode(this.refs.Directory).value;
config.ImageSettings.AmazonS3AccessKeyId = React.findDOMNode(this.refs.AmazonS3AccessKeyId).value; config.FileSettings.AmazonS3AccessKeyId = React.findDOMNode(this.refs.AmazonS3AccessKeyId).value;
config.ImageSettings.AmazonS3SecretAccessKey = React.findDOMNode(this.refs.AmazonS3SecretAccessKey).value; config.FileSettings.AmazonS3SecretAccessKey = React.findDOMNode(this.refs.AmazonS3SecretAccessKey).value;
config.ImageSettings.AmazonS3Bucket = React.findDOMNode(this.refs.AmazonS3Bucket).value; config.FileSettings.AmazonS3Bucket = React.findDOMNode(this.refs.AmazonS3Bucket).value;
config.ImageSettings.AmazonS3Region = React.findDOMNode(this.refs.AmazonS3Region).value; config.FileSettings.AmazonS3Region = React.findDOMNode(this.refs.AmazonS3Region).value;
config.ImageSettings.EnablePublicLink = React.findDOMNode(this.refs.EnablePublicLink).checked; config.FileSettings.EnablePublicLink = React.findDOMNode(this.refs.EnablePublicLink).checked;
config.ImageSettings.PublicLinkSalt = React.findDOMNode(this.refs.PublicLinkSalt).value.trim(); config.FileSettings.PublicLinkSalt = React.findDOMNode(this.refs.PublicLinkSalt).value.trim();
if (config.ImageSettings.PublicLinkSalt === '') { if (config.FileSettings.PublicLinkSalt === '') {
config.ImageSettings.PublicLinkSalt = crypto.randomBytes(256).toString('base64').substring(0, 32); config.FileSettings.PublicLinkSalt = crypto.randomBytes(256).toString('base64').substring(0, 32);
React.findDOMNode(this.refs.PublicLinkSalt).value = config.ImageSettings.PublicLinkSalt; React.findDOMNode(this.refs.PublicLinkSalt).value = config.FileSettings.PublicLinkSalt;
} }
var thumbnailWidth = 120; var thumbnailWidth = 120;
if (!isNaN(parseInt(React.findDOMNode(this.refs.ThumbnailWidth).value, 10))) { if (!isNaN(parseInt(React.findDOMNode(this.refs.ThumbnailWidth).value, 10))) {
thumbnailWidth = parseInt(React.findDOMNode(this.refs.ThumbnailWidth).value, 10); thumbnailWidth = parseInt(React.findDOMNode(this.refs.ThumbnailWidth).value, 10);
} }
config.ImageSettings.ThumbnailWidth = thumbnailWidth; config.FileSettings.ThumbnailWidth = thumbnailWidth;
React.findDOMNode(this.refs.ThumbnailWidth).value = thumbnailWidth; React.findDOMNode(this.refs.ThumbnailWidth).value = thumbnailWidth;
var thumbnailHeight = 100; var thumbnailHeight = 100;
if (!isNaN(parseInt(React.findDOMNode(this.refs.ThumbnailHeight).value, 10))) { if (!isNaN(parseInt(React.findDOMNode(this.refs.ThumbnailHeight).value, 10))) {
thumbnailHeight = parseInt(React.findDOMNode(this.refs.ThumbnailHeight).value, 10); thumbnailHeight = parseInt(React.findDOMNode(this.refs.ThumbnailHeight).value, 10);
} }
config.ImageSettings.ThumbnailHeight = thumbnailHeight; config.FileSettings.ThumbnailHeight = thumbnailHeight;
React.findDOMNode(this.refs.ThumbnailHeight).value = thumbnailHeight; React.findDOMNode(this.refs.ThumbnailHeight).value = thumbnailHeight;
var previewWidth = 1024; var previewWidth = 1024;
if (!isNaN(parseInt(React.findDOMNode(this.refs.PreviewWidth).value, 10))) { if (!isNaN(parseInt(React.findDOMNode(this.refs.PreviewWidth).value, 10))) {
previewWidth = parseInt(React.findDOMNode(this.refs.PreviewWidth).value, 10); previewWidth = parseInt(React.findDOMNode(this.refs.PreviewWidth).value, 10);
} }
config.ImageSettings.PreviewWidth = previewWidth; config.FileSettings.PreviewWidth = previewWidth;
React.findDOMNode(this.refs.PreviewWidth).value = previewWidth; React.findDOMNode(this.refs.PreviewWidth).value = previewWidth;
var previewHeight = 0; var previewHeight = 0;
if (!isNaN(parseInt(React.findDOMNode(this.refs.PreviewHeight).value, 10))) { if (!isNaN(parseInt(React.findDOMNode(this.refs.PreviewHeight).value, 10))) {
previewHeight = parseInt(React.findDOMNode(this.refs.PreviewHeight).value, 10); previewHeight = parseInt(React.findDOMNode(this.refs.PreviewHeight).value, 10);
} }
config.ImageSettings.PreviewHeight = previewHeight; config.FileSettings.PreviewHeight = previewHeight;
React.findDOMNode(this.refs.PreviewHeight).value = previewHeight; React.findDOMNode(this.refs.PreviewHeight).value = previewHeight;
var profileWidth = 128; var profileWidth = 128;
if (!isNaN(parseInt(React.findDOMNode(this.refs.ProfileWidth).value, 10))) { if (!isNaN(parseInt(React.findDOMNode(this.refs.ProfileWidth).value, 10))) {
profileWidth = parseInt(React.findDOMNode(this.refs.ProfileWidth).value, 10); profileWidth = parseInt(React.findDOMNode(this.refs.ProfileWidth).value, 10);
} }
config.ImageSettings.ProfileWidth = profileWidth; config.FileSettings.ProfileWidth = profileWidth;
React.findDOMNode(this.refs.ProfileWidth).value = profileWidth; React.findDOMNode(this.refs.ProfileWidth).value = profileWidth;
var profileHeight = 128; var profileHeight = 128;
if (!isNaN(parseInt(React.findDOMNode(this.refs.ProfileHeight).value, 10))) { if (!isNaN(parseInt(React.findDOMNode(this.refs.ProfileHeight).value, 10))) {
profileHeight = parseInt(React.findDOMNode(this.refs.ProfileHeight).value, 10); profileHeight = parseInt(React.findDOMNode(this.refs.ProfileHeight).value, 10);
} }
config.ImageSettings.ProfileHeight = profileHeight; config.FileSettings.ProfileHeight = profileHeight;
React.findDOMNode(this.refs.ProfileHeight).value = profileHeight; React.findDOMNode(this.refs.ProfileHeight).value = profileHeight;
Client.saveConfig( Client.saveConfig(
@@ -143,7 +143,7 @@ export default class ImageSettings extends React.Component {
return ( return (
<div className='wrapper--fixed'> <div className='wrapper--fixed'>
<h3>{'Image Settings'}</h3> <h3>{'File Settings'}</h3>
<form <form
className='form-horizontal' className='form-horizontal'
role='form' role='form'
@@ -161,7 +161,7 @@ export default class ImageSettings extends React.Component {
className='form-control' className='form-control'
id='DriverName' id='DriverName'
ref='DriverName' ref='DriverName'
defaultValue={this.props.config.ImageSettings.DriverName} defaultValue={this.props.config.FileSettings.DriverName}
onChange={this.handleChange.bind(this, 'DriverName')} onChange={this.handleChange.bind(this, 'DriverName')}
> >
<option value=''>{'Disable File Storage'}</option> <option value=''>{'Disable File Storage'}</option>
@@ -185,7 +185,7 @@ export default class ImageSettings extends React.Component {
id='Directory' id='Directory'
ref='Directory' ref='Directory'
placeholder='Ex "./data/"' placeholder='Ex "./data/"'
defaultValue={this.props.config.ImageSettings.Directory} defaultValue={this.props.config.FileSettings.Directory}
onChange={this.handleChange} onChange={this.handleChange}
disabled={!enableFile} disabled={!enableFile}
/> />
@@ -207,7 +207,7 @@ export default class ImageSettings extends React.Component {
id='AmazonS3AccessKeyId' id='AmazonS3AccessKeyId'
ref='AmazonS3AccessKeyId' ref='AmazonS3AccessKeyId'
placeholder='Ex "AKIADTOVBGERKLCBV"' placeholder='Ex "AKIADTOVBGERKLCBV"'
defaultValue={this.props.config.ImageSettings.AmazonS3AccessKeyId} defaultValue={this.props.config.FileSettings.AmazonS3AccessKeyId}
onChange={this.handleChange} onChange={this.handleChange}
disabled={!enableS3} disabled={!enableS3}
/> />
@@ -229,7 +229,7 @@ export default class ImageSettings extends React.Component {
id='AmazonS3SecretAccessKey' id='AmazonS3SecretAccessKey'
ref='AmazonS3SecretAccessKey' ref='AmazonS3SecretAccessKey'
placeholder='Ex "jcuS8PuvcpGhpgHhlcpT1Mx42pnqMxQY"' placeholder='Ex "jcuS8PuvcpGhpgHhlcpT1Mx42pnqMxQY"'
defaultValue={this.props.config.ImageSettings.AmazonS3SecretAccessKey} defaultValue={this.props.config.FileSettings.AmazonS3SecretAccessKey}
onChange={this.handleChange} onChange={this.handleChange}
disabled={!enableS3} disabled={!enableS3}
/> />
@@ -251,7 +251,7 @@ export default class ImageSettings extends React.Component {
id='AmazonS3Bucket' id='AmazonS3Bucket'
ref='AmazonS3Bucket' ref='AmazonS3Bucket'
placeholder='Ex "mattermost-media"' placeholder='Ex "mattermost-media"'
defaultValue={this.props.config.ImageSettings.AmazonS3Bucket} defaultValue={this.props.config.FileSettings.AmazonS3Bucket}
onChange={this.handleChange} onChange={this.handleChange}
disabled={!enableS3} disabled={!enableS3}
/> />
@@ -273,7 +273,7 @@ export default class ImageSettings extends React.Component {
id='AmazonS3Region' id='AmazonS3Region'
ref='AmazonS3Region' ref='AmazonS3Region'
placeholder='Ex "us-east-1"' placeholder='Ex "us-east-1"'
defaultValue={this.props.config.ImageSettings.AmazonS3Region} defaultValue={this.props.config.FileSettings.AmazonS3Region}
onChange={this.handleChange} onChange={this.handleChange}
disabled={!enableS3} disabled={!enableS3}
/> />
@@ -295,7 +295,7 @@ export default class ImageSettings extends React.Component {
id='ThumbnailWidth' id='ThumbnailWidth'
ref='ThumbnailWidth' ref='ThumbnailWidth'
placeholder='Ex "120"' placeholder='Ex "120"'
defaultValue={this.props.config.ImageSettings.ThumbnailWidth} defaultValue={this.props.config.FileSettings.ThumbnailWidth}
onChange={this.handleChange} onChange={this.handleChange}
/> />
<p className='help-text'>{'Width of thumbnails generated from uploaded images. Updating this value changes how thumbnail images render in future, but does not change images created in the past.'}</p> <p className='help-text'>{'Width of thumbnails generated from uploaded images. Updating this value changes how thumbnail images render in future, but does not change images created in the past.'}</p>
@@ -316,7 +316,7 @@ export default class ImageSettings extends React.Component {
id='ThumbnailHeight' id='ThumbnailHeight'
ref='ThumbnailHeight' ref='ThumbnailHeight'
placeholder='Ex "100"' placeholder='Ex "100"'
defaultValue={this.props.config.ImageSettings.ThumbnailHeight} defaultValue={this.props.config.FileSettings.ThumbnailHeight}
onChange={this.handleChange} onChange={this.handleChange}
/> />
<p className='help-text'>{'Height of thumbnails generated from uploaded images. Updating this value changes how thumbnail images render in future, but does not change images created in the past.'}</p> <p className='help-text'>{'Height of thumbnails generated from uploaded images. Updating this value changes how thumbnail images render in future, but does not change images created in the past.'}</p>
@@ -337,7 +337,7 @@ export default class ImageSettings extends React.Component {
id='PreviewWidth' id='PreviewWidth'
ref='PreviewWidth' ref='PreviewWidth'
placeholder='Ex "1024"' placeholder='Ex "1024"'
defaultValue={this.props.config.ImageSettings.PreviewWidth} defaultValue={this.props.config.FileSettings.PreviewWidth}
onChange={this.handleChange} onChange={this.handleChange}
/> />
<p className='help-text'>{'Maximum width of preview image. Updating this value changes how preview images render in future, but does not change images created in the past.'}</p> <p className='help-text'>{'Maximum width of preview image. Updating this value changes how preview images render in future, but does not change images created in the past.'}</p>
@@ -358,7 +358,7 @@ export default class ImageSettings extends React.Component {
id='PreviewHeight' id='PreviewHeight'
ref='PreviewHeight' ref='PreviewHeight'
placeholder='Ex "0"' placeholder='Ex "0"'
defaultValue={this.props.config.ImageSettings.PreviewHeight} defaultValue={this.props.config.FileSettings.PreviewHeight}
onChange={this.handleChange} onChange={this.handleChange}
/> />
<p className='help-text'>{'Maximum height of preview image ("0": Sets to auto-size). Updating this value changes how preview images render in future, but does not change images created in the past.'}</p> <p className='help-text'>{'Maximum height of preview image ("0": Sets to auto-size). Updating this value changes how preview images render in future, but does not change images created in the past.'}</p>
@@ -379,7 +379,7 @@ export default class ImageSettings extends React.Component {
id='ProfileWidth' id='ProfileWidth'
ref='ProfileWidth' ref='ProfileWidth'
placeholder='Ex "1024"' placeholder='Ex "1024"'
defaultValue={this.props.config.ImageSettings.ProfileWidth} defaultValue={this.props.config.FileSettings.ProfileWidth}
onChange={this.handleChange} onChange={this.handleChange}
/> />
<p className='help-text'>{'Width of profile picture.'}</p> <p className='help-text'>{'Width of profile picture.'}</p>
@@ -400,7 +400,7 @@ export default class ImageSettings extends React.Component {
id='ProfileHeight' id='ProfileHeight'
ref='ProfileHeight' ref='ProfileHeight'
placeholder='Ex "0"' placeholder='Ex "0"'
defaultValue={this.props.config.ImageSettings.ProfileHeight} defaultValue={this.props.config.FileSettings.ProfileHeight}
onChange={this.handleChange} onChange={this.handleChange}
/> />
<p className='help-text'>{'Height of profile picture.'}</p> <p className='help-text'>{'Height of profile picture.'}</p>
@@ -421,7 +421,7 @@ export default class ImageSettings extends React.Component {
name='EnablePublicLink' name='EnablePublicLink'
value='true' value='true'
ref='EnablePublicLink' ref='EnablePublicLink'
defaultChecked={this.props.config.ImageSettings.EnablePublicLink} defaultChecked={this.props.config.FileSettings.EnablePublicLink}
onChange={this.handleChange} onChange={this.handleChange}
/> />
{'true'} {'true'}
@@ -431,7 +431,7 @@ export default class ImageSettings extends React.Component {
type='radio' type='radio'
name='EnablePublicLink' name='EnablePublicLink'
value='false' value='false'
defaultChecked={!this.props.config.ImageSettings.EnablePublicLink} defaultChecked={!this.props.config.FileSettings.EnablePublicLink}
onChange={this.handleChange} onChange={this.handleChange}
/> />
{'false'} {'false'}
@@ -454,7 +454,7 @@ export default class ImageSettings extends React.Component {
id='PublicLinkSalt' id='PublicLinkSalt'
ref='PublicLinkSalt' ref='PublicLinkSalt'
placeholder='Ex "gxHVDcKUyP2y1eiyW8S8na1UYQAfq6J6"' placeholder='Ex "gxHVDcKUyP2y1eiyW8S8na1UYQAfq6J6"'
defaultValue={this.props.config.ImageSettings.PublicLinkSalt} defaultValue={this.props.config.FileSettings.PublicLinkSalt}
onChange={this.handleChange} onChange={this.handleChange}
/> />
<p className='help-text'>{'32-character salt added to signing of public image links.'}</p> <p className='help-text'>{'32-character salt added to signing of public image links.'}</p>
@@ -491,6 +491,6 @@ export default class ImageSettings extends React.Component {
} }
} }
ImageSettings.propTypes = { FileSettings.propTypes = {
config: React.PropTypes.object config: React.PropTypes.object
}; };

Просмотреть файл

@@ -4,7 +4,7 @@
const ChoosePage = require('./team_signup_choose_auth.jsx'); const ChoosePage = require('./team_signup_choose_auth.jsx');
const EmailSignUpPage = require('./team_signup_with_email.jsx'); const EmailSignUpPage = require('./team_signup_with_email.jsx');
const SSOSignupPage = require('./team_signup_with_sso.jsx'); const SSOSignupPage = require('./team_signup_with_sso.jsx');
var Constants = require('../utils/constants.jsx'); const Constants = require('../utils/constants.jsx');
export default class TeamSignUp extends React.Component { export default class TeamSignUp extends React.Component {
constructor(props) { constructor(props) {