是否可以将 PLUpload 与 CouchDB 结合使用?
我正在寻找将图像上传到我的 CouchDB 并在上传之前调整它们大小的可能性,只要它们仍在客户端中即可。 PLUpload 提供了这样做的可能性,但我想知道是否可以将它与 CouchDB 一起使用。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
经过大量尝试和阅读,我终于成功使用 PLUpload 将图片上传到 CouchDB。
主要问题是有一个未记录的属性“file_data_name”,必须手动设置该属性才能满足 CouchDB 的需求。默认值为“name”,但 CouchDB 需要“_attachments”。我只是通过检查 Flash 运行时的源代码才发现该属性。
下面是我用来初始化 PLUpload 的 javascript:
但是使用这种方法只能将一张图像发送到一个文档。上传到多个文档不起作用,但我还没有真正尝试过。
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:
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).
您想要做的是覆盖 PLUploader 的 BeforeUpload 事件,以便在上传文件之前使用您的 couch 实例。在下面的方法中,我创建一个新文档(使用 jquery.couch.js),获取响应并使用新文档的新 _id 和 _rev 来设置 PLUploader 实例选项。
What you want to do is override the BeforeUpload event of PLUploader to work with your couch instance before uploading the file. In the method below, I am creating a new document (using jquery.couch.js), getting the response and using the new _id and _rev of the new document to set the PLUploader instance options.