コード例 #1
0
  /**
   * 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();
    }
  }
コード例 #2
0
  /**
   * 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();
    }
  }
コード例 #3
0
 @Kroll.setProperty(name = "userProperties")
 public void setUserProperties(KrollDict properties) {
   ((UnsavedRevision) revision).setUserProperties(properties);
 }
コード例 #4
0
 @Kroll.method
 public void setPropertyForKey(String key, Object value) {
   ((UnsavedRevision) revision).getProperties().put(key, value);
 }
コード例 #5
0
 @Kroll.setProperty(name = "isDeletion")
 public void setDeletion(boolean deletion) {
   ((UnsavedRevision) revision).setIsDeletion(deletion);
 }
コード例 #6
0
 @Kroll.method
 public void setAttachment(String name, String contentType, TiBlob content) {
   ((UnsavedRevision) revision).setAttachment(name, contentType, content.getInputStream());
 }
コード例 #7
0
 @Kroll.method
 public void removeAttachment(String name) {
   ((UnsavedRevision) revision).removeAttachment(name);
   // TODO attachment cache
 }