2017-09-13 38 views
0

我正在尝试将附件添加到现有文档。我正在使用nano库来发送数据和附件,以便以后通过CBLite进行访问。获取409尝试通过Sync Gateway将附件插入到现有文档

我从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'); 

```

回答

0

,我发现了问题所在:filename字符串包含#字符等是造成问题,更改名称/移除有问题的角色似乎已经解决了这个问题。

相关问题