summaryrefslogtreecommitdiffstats
path: root/web/react/utils/utils.jsx
diff options
context:
space:
mode:
authorhmhealey <harrisonmhealey@gmail.com>2015-07-28 11:30:22 -0400
committerhmhealey <harrisonmhealey@gmail.com>2015-07-29 10:03:42 -0400
commitf66cd5e9773a38cca635d33d91f0ef3b056d94a0 (patch)
tree2582063489d5b6ded95ba47cb73043debaa1a895 /web/react/utils/utils.jsx
parent0e121a68de2d99ac17b27e41d92efae7721c6578 (diff)
downloadchat-f66cd5e9773a38cca635d33d91f0ef3b056d94a0.tar.gz
chat-f66cd5e9773a38cca635d33d91f0ef3b056d94a0.tar.bz2
chat-f66cd5e9773a38cca635d33d91f0ef3b056d94a0.zip
Added utility function to get a file attachment's url
Diffstat (limited to 'web/react/utils/utils.jsx')
-rw-r--r--web/react/utils/utils.jsx13
1 files changed, 13 insertions, 0 deletions
diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx
index e48ffed9a..d1513dea9 100644
--- a/web/react/utils/utils.jsx
+++ b/web/react/utils/utils.jsx
@@ -894,3 +894,16 @@ module.exports.fileSizeToString = function(bytes) {
return bytes + "B";
}
};
+
+// Converts a filename (like those attached to Post objects) to a url that can be used to retrieve attachments from the server.
+module.exports.getFileUrl = function(filename) {
+ var url = filename;
+
+ // This is a temporary patch to fix issue with old files using absolute paths
+ if (url.indexOf("/api/v1/files/get") != -1) {
+ url = filename.split("/api/v1/files/get")[1];
+ }
+ url = module.exports.getWindowLocationOrigin() + "/api/v1/files/get" + url;
+
+ return url;
+};