Permalink
Browse files

merged

  • Loading branch information...
2 parents 30b658f + d0ae4ad commit 85378f355571c06a9a87e43a14430c0f06a771de @soitgoes soitgoes committed Jan 28, 2010
Showing with 6 additions and 5 deletions.
  1. +6 −5 lib/couchdb/database.js
View
@@ -356,7 +356,7 @@ var Database = {
},
addAttachmentToDoc: function(doc, attachmentName, contentType, attachmentData) {
- var response = true;
+ var status;
if (doc._rev === undefined) {
throw new Error("Argument 'doc' must have a '_rev' property in order to add attachments.");
@@ -366,18 +366,19 @@ var Database = {
}
var uri = this.uri + doc._id + "/" + attachmentName + "?rev=" + doc._rev;
+
this.httpClient.put(uri, {
headers: [ { "label" : "Content-Type", "value": contentType }],
data: attachmentData.toArray(),
binary: true,
async: false,
dataType: "json",
success: function(data, textStatus) {
- if (!data.ok) {
+ status = textStatus;
+ if (!data.ok) {
response = false;
- return;
+ return status;
}
- doc._rev = data.rev;
},
error: function(xhr, textStatus, errorThrown) {
textStatus = textStatus || "";
@@ -386,7 +387,7 @@ var Database = {
}
});
- return response;
+ return status;
},
removeAttachmentFromDoc: function(doc, attachmentName) {
var response = true;

0 comments on commit 85378f3

Please sign in to comment.