批量上传Couchdb附件?
问题说明
我正在将sqlite数据库转换为Couchdb.我可以转换数据库并上传到Couchdb服务器.除了图像以外的所有内容.我想将图像作为独立的附件上传,我想使用javascript,REST和xhr批量进行此操作.
I am converting my sqlite database to Couchdb. I can convert the db and upload to the Couchdb server. Everything but the images. I want to upload the images as standalone attachments and I would like to do this in bulk using javascript, REST, and xhr.
POST http://127.0.0.1:5984/database/_bulk_docs
Data : {"_id": "701", "_attachments": {"555_image.png": { "content_type": "image/jpg","data":[object TiFilesystemFile] }}}
我已经对单个文件进行了CURL测试,并且可以正常工作.我该怎么做?
I have CURLed a single file to test and that works. How do I do bulk?
这是由Appcelerator Titanium开发的iOS应用.
This is and iOS app developed with Appcelerator Titanium.
正确答案
您应该能够调整单个文件,并执行以下操作:
You should be able to adjust your single file, and do something like the following:
POST http://127.0.0.1:5984/database/_bulk_docs
数据为:
{
"docs": [
{"_id": "701", "_attachments": {"555_image.png": { "content_type": "image/jpg","data":[object TiFilesystemFile] }},
{"_id": "702", "_attachments": {"556_image.png": { "content_type": "image/jpg","data":[object TiFilesystemFile] }},
{"_id": "703", "_attachments": {"557_image.png": { "content_type": "image/jpg","data":[object TiFilesystemFile] }},
]
}
但是,根据附件的数量和大小,您可能会遇到问题.最好简单地循环并一次执行一次.或至少按合理大小的批次进行.
However, depending on the number and size of attachments you might run into problems. It might be better to simply loop and do them one at a time; or at least in reasonably sized batches.
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /reply/detail/tanhcckhfj
-
YouTube API 不能在 iOS (iPhone/iPad) 工作,但在桌面浏览器工作正常?
it1352 07-30 -
iPhone,一张图像叠加到另一张图像上以创建要保存的新图像?(水印)
it1352 07-17 -
保持在后台运行的 iPhone 应用程序完全可操作
it1352 07-25 -
使用 iPhone 进行移动设备管理
it1352 07-23 -
在android同时打开手电筒和前置摄像头
it1352 09-28 -
扫描 NFC 标签时是否可以启动应用程序?
it1352 08-02 -
检查邮件是否发送成功
it1352 07-25 -
Android微调工具-删除当前选择
it1352 06-20 -
希伯来语的空格句子标记化错误
it1352 06-22 -
Android App 和三星 Galaxy S4 不兼容
it1352 07-20