couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject [1/3] git commit: updated refs/heads/master to 9750512
Date Sat, 30 Mar 2013 21:36:47 GMT
Updated Branches:
  refs/heads/master 5fa09a38e -> 97505126c


Test attachment upload via multipart/form-data

This is used in Futon attachment upload.


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/fe2dca09
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/fe2dca09
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/fe2dca09

Branch: refs/heads/master
Commit: fe2dca093a629097b9d0e1e0575e9044a5908df3
Parents: e18f0bd
Author: Johannes J. Schmidt <schmidt@netzmerk.com>
Authored: Wed Mar 27 23:59:16 2013 +0100
Committer: Johannes J. Schmidt <schmidt@netzmerk.com>
Committed: Wed Mar 27 23:59:16 2013 +0100

----------------------------------------------------------------------
 share/www/script/test/attachments.js |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/fe2dca09/share/www/script/test/attachments.js
----------------------------------------------------------------------
diff --git a/share/www/script/test/attachments.js b/share/www/script/test/attachments.js
index db4524a..2fa08ee 100644
--- a/share/www/script/test/attachments.js
+++ b/share/www/script/test/attachments.js
@@ -298,4 +298,31 @@ couchTests.attachments= function(debug) {
   var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc7/attachment.txt");
   TEquals('MntvB0NYESObxH4VRDUycw==', xhr.getResponseHeader("Content-MD5"));
 
+  // test attachment via multipart/form-data
+  var bin_doc8 = {
+    _id: "bin_doc8"
+  };
+  T(db.save(bin_doc8).ok);
+  var doc = db.open("bin_doc8");
+  var body = "------TF\r\n" +
+    "Content-Disposition: form-data; name=\"_rev\"\r\n\r\n" +
+    doc._rev + "\r\n" +
+    "------TF\r\n" +
+    "Content-Disposition: form-data; name=\"_attachments\"; filename=\"file.txt\"\r\n" +
+    "Content-Type: text/plain\r\n\r\n" +
+    "contents of file.txt\r\n\r\n" +
+    "------TF--"
+  xhr = CouchDB.request("POST", "/test_suite_db/bin_doc8", {
+    headers: {
+      "Content-Type": "multipart/form-data; boundary=----TF",
+      "Content-Length": body.length
+    },
+    body: body
+  });
+  TEquals(201, xhr.status);
+  TEquals(true, JSON.parse(xhr.responseText).ok);
+  var doc = db.open("bin_doc8");
+  T(doc._attachments);
+  T(doc._attachments['file.txt']);
+
 };


Mime
View raw message