0
既存の文書に添付ファイルを追加しようとしています。私はnanoライブラリを使用してデータと添付ファイルを送信し、後でCBLite経由でアクセスします。同期ゲートウェイ経由で既存の文書に添付ファイルを挿入しようとしています。
私がdb.attachment.insert
から作成したドキュメントは問題ありません。しかし、ドキュメントごとに複数の添付ファイルを追加する必要がありました。私は409の問題に取り組んでいます。具体的に私が取得しています:
文書は、私は現在のリビジョンが送信されていることを確認しました
が存在します。
try {
let response = await db.getAsync(docId);
rev = response._rev;
console.log ('existing entry, rev:' + rev);
} catch (error) {
console.log ('new entry');
let docRes = await db.insertAsync(word, docId);
console.log (docRes);
rev = docRes.rev;
}
//...
var data = {};
try {
data = await fs.readFile(filePath);
} catch (ex) {
console.log ("error: "+filePath);
console.log (ex);
continue;
}
if (data) {
try {
console.log ('inserting '+filename+' at rev', rev);
let res = await db.attachment.insertAsync(docId, filename, data, 'audio/mpeg', {rev: rev});
console.log('attachment inserted', res);
} catch (error) {
console.log (error.statusCode);
console.log (error.message);
}
} else console.log('file data empty');
`` `