Skip to content

Commit 7017e6c

Browse files
committed
Fix attachment filenames in multipart uploads
Also if an attachment is missing do not upload the multipart revision, even if the next attachment is not missing.
1 parent 69aa7c0 commit 7017e6c

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

src/main/java/com/couchbase/lite/replicator/PusherInternal.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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

@@ -730,8 +728,8 @@ private static int findCommonAncestor(RevisionInternal rev, List<String> possibl
730728
private static class CustomFileBody extends FileBody {
731729
private String contentEncoding = null;
732730

733-
public CustomFileBody(final File file, final String mimeType, final String contentEncoding) {
734-
super(file, mimeType);
731+
public CustomFileBody(File file, String filename, String mimeType, String contentEncoding) {
732+
super(file, filename, mimeType, null);
735733
this.contentEncoding = contentEncoding;
736734
}
737735

0 commit comments

Comments
 (0)