/**
   * Write an Attachment for a given Document
   *
   * @param docId
   * @param attachName
   * @param mimeType e.g. "image/jpeg"
   * @param in
   */
  public void writeAttachment(String docId, String attachName, String mimeType, InputStream in) {

    try {
      Document doc = database.getDocument(docId);
      UnsavedRevision newRev = doc.getCurrentRevision().createRevision();
      newRev.setAttachment(attachName, mimeType, in);
      newRev.save();
    } catch (CouchbaseLiteException e) {
      e.printStackTrace();
    }
  }
  /**
   * Remove an Attachment from a Document
   *
   * @param docId
   * @param attachName
   */
  public void deleteAttachment(String docId, String attachName) {

    try {
      Document doc = database.getDocument(docId);
      UnsavedRevision newRev = doc.getCurrentRevision().createRevision();
      newRev.removeAttachment(attachName);
      // (You could also update newRev.properties while you're here)
      newRev.save();
    } catch (CouchbaseLiteException e) {
      e.printStackTrace();
    }
  }
Esempio n. 3
0
 @Kroll.setProperty(name = "userProperties")
 public void setUserProperties(KrollDict properties) {
   ((UnsavedRevision) revision).setUserProperties(properties);
 }
Esempio n. 4
0
 @Kroll.method
 public void setPropertyForKey(String key, Object value) {
   ((UnsavedRevision) revision).getProperties().put(key, value);
 }
Esempio n. 5
0
 @Kroll.setProperty(name = "isDeletion")
 public void setDeletion(boolean deletion) {
   ((UnsavedRevision) revision).setIsDeletion(deletion);
 }
Esempio n. 6
0
 @Kroll.method
 public void setAttachment(String name, String contentType, TiBlob content) {
   ((UnsavedRevision) revision).setAttachment(name, contentType, content.getInputStream());
 }
Esempio n. 7
0
 @Kroll.method
 public void removeAttachment(String name) {
   ((UnsavedRevision) revision).removeAttachment(name);
   // TODO attachment cache
 }