Added utility function to get a file attachment's url

Этот коммит содержится в:
hmhealey
2015-07-28 11:30:22 -04:00
родитель 0e121a68de
Коммит f66cd5e977
2 изменённых файлов: 14 добавлений и 9 удалений

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

@@ -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;
};