Merge pull request #466 from mattermost/mm-1912

Fixes mm-1912 move get file info into its own web service call
Этот коммит содержится в:
Corey Hulen
2015-08-25 13:17:21 -07:00
родитель b4ee263730 64b179ab0e
Коммит eb5af31c17
7 изменённых файлов: 131 добавлений и 35 удалений

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

@@ -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',

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

@@ -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();