1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-13 23:03:32 +00:00

upload new attachments

This commit is contained in:
Kyle Spearrin
2017-07-12 09:57:08 -04:00
parent 89b1639dda
commit 0574c538e7
8 changed files with 225 additions and 65 deletions

View File

@@ -403,6 +403,47 @@ function initApiService() {
});
};
ApiService.prototype.postCipherAttachment = function (id, formData, success, error) {
var self = this;
handleTokenState(self).then(function (token) {
$.ajax({
type: 'POST',
url: self.baseUrl + '/ciphers/' + id + '/attachment?' + token,
data: formData,
processData: false,
contentType: false,
dataType: 'json',
success: function (response) {
success(new CipherResponse(response));
},
error: function (jqXHR, textStatus, errorThrown) {
handleError(error, jqXHR, false, self);
}
});
}, function (jqXHR) {
handleError(error, jqXHR, true, self);
});
};
ApiService.prototype.deleteCipherAttachment = function (id, attachmentId, success, error) {
var self = this;
handleTokenState(self).then(function (token) {
$.ajax({
type: 'POST',
url: self.baseUrl + '/ciphers/' + id + '/attachment/' + attachmentId + '/delete?' + token,
dataType: 'text',
success: function (response) {
success();
},
error: function (jqXHR, textStatus, errorThrown) {
handleError(error, jqXHR, false, self);
}
});
}, function (jqXHR) {
handleError(error, jqXHR, true, self);
});
};
// Helpers
function handleError(errorCallback, jqXHR, tokenError, self) {