summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2015-07-21 16:15:24 -0400
committerChristopher Speller <crspeller@gmail.com>2015-07-21 16:25:49 -0400
commitf5837c1b64994a15537a0b8df109bed504d0d20a (patch)
tree1799709f9eda102a9a4505568b4a3faa917afa52
parentbee26e3f2654ce7acce647818847480569236343 (diff)
downloadchat-f5837c1b64994a15537a0b8df109bed504d0d20a.tar.gz
chat-f5837c1b64994a15537a0b8df109bed504d0d20a.tar.bz2
chat-f5837c1b64994a15537a0b8df109bed504d0d20a.zip
Old files are saved with full paths, this changes so that new files are not saved with absolute paths and detects old files saved and fixes them.
-rw-r--r--api/file.go2
-rw-r--r--web/react/components/post_body.jsx12
2 files changed, 13 insertions, 1 deletions
diff --git a/api/file.go b/api/file.go
index 362cdf896..5d676b9fd 100644
--- a/api/file.go
+++ b/api/file.go
@@ -115,7 +115,7 @@ func uploadFile(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
- fileUrl := c.GetSiteURL() + "/api/v1/files/get/" + channelId + "/" + c.Session.UserId + "/" + uid + "/" + url.QueryEscape(files[i].Filename)
+ fileUrl := "/" + channelId + "/" + c.Session.UserId + "/" + uid + "/" + url.QueryEscape(files[i].Filename)
resStruct.Filenames = append(resStruct.Filenames, fileUrl)
}
diff --git a/web/react/components/post_body.jsx b/web/react/components/post_body.jsx
index d9678df30..96b441c0e 100644
--- a/web/react/components/post_body.jsx
+++ b/web/react/components/post_body.jsx
@@ -28,6 +28,12 @@ module.exports = React.createClass({
var type = utils.getFileType(fileInfo.ext);
+ // This is a temporary patch to fix issue with old files using absolute paths
+ if (fileInfo.path.indexOf("/api/v1/files/get") == -1) {
+ fileInfo.path = fileInfo.path.split("/api/v1/files/get")[1];
+ }
+ fileInfo.path = window.location.origin + "/api/v1/files/get" + fileInfo.path;
+
if (type === "image") {
$('<img/>').attr('src', fileInfo.path+'_thumb.jpg').load(function(path, name){ return function() {
$(this).remove();
@@ -102,6 +108,12 @@ module.exports = React.createClass({
var type = utils.getFileType(fileInfo.ext);
+ // This is a temporary patch to fix issue with old files using absolute paths
+ if (fileInfo.path.indexOf("/api/v1/files/get") == -1) {
+ fileInfo.path = fileInfo.path.split("/api/v1/files/get")[1];
+ }
+ fileInfo.path = window.location.origin + "/api/v1/files/get" + fileInfo.path;
+
if (type === "image") {
if (i < Constants.MAX_DISPLAY_FILES) {
postFiles.push(