I am looking for some possibility of uploading images to my CouchDB and resizing them before the upload as long as they are still with the client. PLUpload offers a possibility for doing so but I wonder if it possible to use it together with CouchDB.
After a lot of trying and reading I finally managed to upload a picture to CouchDB using PLUpload. The main problem was that there is an undocumented property "file_data_name" which has to be set manually to fit with the needs from CouchDB. The default value is "name" but CouchDB is expecting "_attachments". I only found that property by inspecting the source code for the flash runtime.
Below there is the javascript I used for initializing the PLUpload:
$("form#pluploadForm #uploader").plupload({
// General settings
runtimes : 'flash,silverlight,html5',
url : 'http://your.path.to.couchdb.com/database/[documentid]',
max_file_size : '10mb',
unique_names : true,
file_data_name : "_attachments",
// Resize images on clientside if we can
resize : {width : 320, height : 240, quality : 90},
// Specify what files to browse for
filters : [
{title : "Image files", extensions : "jpg,gif,png"},
{title : "Zip files", extensions : "zip"}
],
// Flash settings
flash_swf_url : 'js/plupload.flash.swf',
// Silverlight settings
silverlight_xap_url : 'js/plupload.silverlight.xap',
multipart : true,
multipart_params : {
description: "uploadedViaPlupload",
_rev: "[the current revision of your document]",
}
});
But with this approach it is only possible to one image to one single document. Uploading to multiple documents isn't working but I didn't really try it (yet).