@@ -602,14 +602,12 @@ private boolean uploadMultipartRevision(final RevisionInternal revision) {
602602 File file = new File (path );
603603 if (!file .exists ()) {
604604 Log .w (Log .TAG_SYNC , "Unable to find blob file for blobKey: %s - Skipping upload of multipart revision." , blobKey );
605- multiPart = null ;
606- }
607- else {
605+ return false ;
606+ } else {
608607 String contentType = null ;
609608 if (attachment .containsKey ("content_type" )) {
610609 contentType = (String ) attachment .get ("content_type" );
611- }
612- else if (attachment .containsKey ("content-type" )) {
610+ } else if (attachment .containsKey ("content-type" )) {
613611 Log .w (Log .TAG_SYNC , "Found attachment that uses content-type" +
614612 " field name instead of content_type (see couchbase-lite-android" +
615613 " issue #80): %s" , attachment );
@@ -623,7 +621,7 @@ else if (attachment.containsKey("content-type")) {
623621 contentEncoding = (String )attachment .get ("encoding" );
624622 }
625623
626- FileBody fileBody = new CustomFileBody (file , contentType , contentEncoding );
624+ FileBody fileBody = new CustomFileBody (file , attachmentKey , contentType , contentEncoding );
627625 multiPart .addPart (attachmentKey , fileBody );
628626 }
629627
@@ -634,7 +632,7 @@ else if (attachment.containsKey("content-type")) {
634632 return false ;
635633 }
636634
637- final String path = String .format ("/%s?new_edits=false" , revision .getDocId ());
635+ final String path = String .format ("/%s?new_edits=false" , encodeDocumentId ( revision .getDocId () ));
638636
639637 Log .d (Log .TAG_SYNC , "Uploading multipart request. Revision: %s" , revision );
640638
@@ -683,7 +681,7 @@ private void uploadJsonRevision(final RevisionInternal rev) {
683681 return ;
684682 }
685683
686- final String path = String .format ("/%s?new_edits=false" , URIUtils . encode (rev .getDocId ()));
684+ final String path = String .format ("/%s?new_edits=false" , encodeDocumentId (rev .getDocId ()));
687685 Future future = sendAsyncRequest ("PUT" ,
688686 path ,
689687 rev .getProperties (),
@@ -700,9 +698,6 @@ public void onCompletion(HttpResponse httpResponse, Object result, Throwable e)
700698 pendingFutures .add (future );
701699 }
702700
703-
704-
705-
706701 // Given a revision and an array of revIDs, finds the latest common ancestor revID
707702 // and returns its generation #. If there is none, returns 0.
708703 private static int findCommonAncestor (RevisionInternal rev , List <String > possibleRevIDs ) {
@@ -730,8 +725,8 @@ private static int findCommonAncestor(RevisionInternal rev, List<String> possibl
730725 private static class CustomFileBody extends FileBody {
731726 private String contentEncoding = null ;
732727
733- public CustomFileBody (final File file , final String mimeType , final String contentEncoding ) {
734- super (file , mimeType );
728+ public CustomFileBody (File file , String filename , String mimeType , String contentEncoding ) {
729+ super (file , filename , mimeType , null );
735730 this .contentEncoding = contentEncoding ;
736731 }
737732
0 commit comments