You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ga...@apache.org on 2013/05/09 16:01:04 UTC
[07/50] git commit: updated refs/heads/route-events to c33e390
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/2c586f7c
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/2c586f7c
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/2c586f7c
Branch: refs/heads/route-events
Commit: 2c586f7c155a483caf37adddc371dd862013dbdc
Parents: 68bf3c6
Author: Johannes J. Schmidt <sc...@netzmerk.com>
Authored: Wed Mar 27 23:59:16 2013 +0100
Committer: Garren Smith <ga...@gmail.com>
Committed: Thu May 9 09:59:54 2013 +0200
----------------------------------------------------------------------
share/www/script/test/attachments.js | 27 +++++++++++++++++++++++++++
1 files changed, 27 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/2c586f7c/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']);
+
};