2017-09-13 39 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字符串包含#字符等是造成問題,更改名稱/移除有問題的角色似乎已經解決了這個問題。

相關問題