Skip to content

Commit

Permalink
merged
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Murphy committed Jan 28, 2010
2 parents 30b658f + d0ae4ad commit 85378f3
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/couchdb/database.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ var Database = {


}, },
addAttachmentToDoc: function(doc, attachmentName, contentType, attachmentData) { addAttachmentToDoc: function(doc, attachmentName, contentType, attachmentData) {
var response = true; var status;


if (doc._rev === undefined) { if (doc._rev === undefined) {
throw new Error("Argument 'doc' must have a '_rev' property in order to add attachments."); throw new Error("Argument 'doc' must have a '_rev' property in order to add attachments.");
Expand All @@ -366,18 +366,19 @@ var Database = {
} }


var uri = this.uri + doc._id + "/" + attachmentName + "?rev=" + doc._rev; var uri = this.uri + doc._id + "/" + attachmentName + "?rev=" + doc._rev;

this.httpClient.put(uri, { this.httpClient.put(uri, {
headers: [ { "label" : "Content-Type", "value": contentType }], headers: [ { "label" : "Content-Type", "value": contentType }],
data: attachmentData.toArray(), data: attachmentData.toArray(),
binary: true, binary: true,
async: false, async: false,
dataType: "json", dataType: "json",
success: function(data, textStatus) { success: function(data, textStatus) {
if (!data.ok) { status = textStatus;
if (!data.ok) {
response = false; response = false;
return; return status;
} }
doc._rev = data.rev;
}, },
error: function(xhr, textStatus, errorThrown) { error: function(xhr, textStatus, errorThrown) {
textStatus = textStatus || ""; textStatus = textStatus || "";
Expand All @@ -386,7 +387,7 @@ var Database = {
} }
}); });


return response; return status;
}, },
removeAttachmentFromDoc: function(doc, attachmentName) { removeAttachmentFromDoc: function(doc, attachmentName) {
var response = true; var response = true;
Expand Down

0 comments on commit 85378f3

Please sign in to comment.