• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

批量上传Couchdb附件?

用户头像
it1352
帮助1

问题说明

我正在将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.

正确答案

#1

您应该能够调整单个文件,并执行以下操作:

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
系列文章
更多 icon
同类精品
更多 icon
继续加载