Merge pull request #359 from hmhealey/mm1770
MM-1770 Add the ability to cancel in-progress file uploads
Этот коммит содержится в:
@@ -754,7 +754,7 @@ module.exports.getProfiles = function(success, error) {
|
||||
};
|
||||
|
||||
module.exports.uploadFile = function(formData, success, error) {
|
||||
$.ajax({
|
||||
var request = $.ajax({
|
||||
url: "/api/v1/files/upload",
|
||||
type: 'POST',
|
||||
data: formData,
|
||||
@@ -763,12 +763,16 @@ module.exports.uploadFile = function(formData, success, error) {
|
||||
processData: false,
|
||||
success: success,
|
||||
error: function(xhr, status, err) {
|
||||
e = handleError("uploadFile", xhr, status, err);
|
||||
error(e);
|
||||
if (err !== 'abort') {
|
||||
e = handleError("uploadFile", xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
module.exports.track('api', 'api_files_upload');
|
||||
|
||||
return request;
|
||||
};
|
||||
|
||||
module.exports.getPublicLink = function(data, success, error) {
|
||||
|
||||
@@ -913,3 +913,24 @@ module.exports.getFileName = function(path) {
|
||||
var split = path.split('/');
|
||||
return split[split.length - 1];
|
||||
};
|
||||
|
||||
// Generates a RFC-4122 version 4 compliant globally unique identifier.
|
||||
module.exports.generateId = function() {
|
||||
// implementation taken from http://stackoverflow.com/a/2117523
|
||||
var id = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
|
||||
|
||||
id = id.replace(/[xy]/g, function(c) {
|
||||
var r = Math.floor(Math.random() * 16);
|
||||
|
||||
var v;
|
||||
if (c === 'x') {
|
||||
v = r;
|
||||
} else {
|
||||
v = r & 0x3 | 0x8;
|
||||
}
|
||||
|
||||
return v.toString(16);
|
||||
});
|
||||
|
||||
return id;
|
||||
};
|
||||
|
||||
Ссылка в новой задаче
Block a user