diff --git a/scripts/attachment.js b/scripts/attachment.js index ca1c36e..a19ba61 100644 --- a/scripts/attachment.js +++ b/scripts/attachment.js @@ -4,29 +4,21 @@ var Attachment = function (slouch) { this._slouch = slouch; }; -// TODO -// Attachment.prototype.create = function (dbName, docId, attachmentName, data, contentType, rev) { -// var formData = { -// custom_file: { -// value: data, -// options: { -// filename: attachmentName, -// contentType: contentType -// } -// } -// }; -// -// return this._slouch._req({ -// uri: this._slouch._url + '/' + dbName + '/' + docId + '/' + attachmentName + -// '?rev=' + encodeURIComponent(rev), -// method: 'PUT', -// // raw: true, -// // encoding: null, -// formData: formData -// }).then(function (response) { -// return response.body; -// }); -// }; +Attachment.prototype.create = function (dbName, docId, attachmentName, data, contentType, rev) { + return this._slouch._req({ + uri: this._slouch._url + '/' + encodeURIComponent(dbName) + '/' + encodeURIComponent( + docId) + '/' + encodeURIComponent(attachmentName) + '?rev=' + encodeURIComponent(rev), + method: 'PUT', + headers: { + 'Content-Type': contentType + }, + raw: true, + encoding: null, + body: data + }).then(function (response) { + return response.body; + }); +}; Attachment.prototype.get = function (dbName, docId, attachmentName) { return this._slouch._req({