summaryrefslogtreecommitdiffstats
path: root/web/react/utils
diff options
context:
space:
mode:
author=Corey Hulen <corey@hulen.com>2015-08-24 15:03:52 -0700
committer=Corey Hulen <corey@hulen.com>2015-08-24 15:03:52 -0700
commit64b179ab0e6a66c0f8edb72ab24ef28bbc2f9969 (patch)
tree3094d69abb3e9bd32a14587c8d787c9ad8f0b688 /web/react/utils
parent930488f002c819efed7e3afc982b73d1c06a9bbe (diff)
downloadchat-64b179ab0e6a66c0f8edb72ab24ef28bbc2f9969.tar.gz
chat-64b179ab0e6a66c0f8edb72ab24ef28bbc2f9969.tar.bz2
chat-64b179ab0e6a66c0f8edb72ab24ef28bbc2f9969.zip
Fixes mm-1912 move get file info into its own web service call
Diffstat (limited to 'web/react/utils')
-rw-r--r--web/react/utils/client.jsx14
-rw-r--r--web/react/utils/utils.jsx17
2 files changed, 14 insertions, 17 deletions
diff --git a/web/react/utils/client.jsx b/web/react/utils/client.jsx
index 754843697..13d6c3f54 100644
--- a/web/react/utils/client.jsx
+++ b/web/react/utils/client.jsx
@@ -831,6 +831,20 @@ module.exports.uploadFile = function(formData, success, error) {
return request;
};
+module.exports.getFileInfo = function(filename, success, error) {
+ $.ajax({
+ url: '/api/v1/files/get_info' + filename,
+ dataType: 'json',
+ contentType: 'application/json',
+ type: 'GET',
+ success: success,
+ error: function onError(xhr, status, err) {
+ var e = handleError('getFileInfo', xhr, status, err);
+ error(e);
+ }
+ });
+};
+
module.exports.getPublicLink = function(data, success, error) {
$.ajax({
url: '/api/v1/files/get_public_link',
diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx
index 4571312bb..1a4db5954 100644
--- a/web/react/utils/utils.jsx
+++ b/web/react/utils/utils.jsx
@@ -604,23 +604,6 @@ module.exports.splitFileLocation = function(fileLocation) {
return {ext: ext, name: filename, path: filePath};
};
-// Asynchronously gets the size of a file by requesting its headers. If successful, it calls the
-// provided callback with the file size in bytes as the argument.
-module.exports.getFileSize = function(url, callback) {
- var request = new XMLHttpRequest();
-
- request.open('HEAD', url, true);
- request.onreadystatechange = function onReadyStateChange() {
- if (request.readyState === 4 && request.status === 200) {
- if (callback) {
- callback(parseInt(request.getResponseHeader('content-length'), 10));
- }
- }
- };
-
- request.send();
-};
-
module.exports.toTitleCase = function(str) {
function doTitleCase(txt) {
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();