[ 
https://issues.apache.org/jira/browse/JCRVLT-186?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16066651#comment-16066651
 ] 

Tobias Bocanegra edited comment on JCRVLT-186 at 6/28/17 3:12 PM:
------------------------------------------------------------------

good catch! I needed to add the filename parameter for the un-chunked test (see 
diff above). that's probably why it worked. 

I tried to add the filename parameter for the chunked case:

{noformat}
diff --git 
a/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2davex/Utils.java 
b/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2davex/Utils.java
index e4ddbf261..7fd552700 100644
--- 
a/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2davex/Utils.java
+++ 
b/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2davex/Utils.java
@@ -98,7 +99,7 @@ final class Utils {
         switch (value.getType()) {
             case PropertyType.BINARY:
                 binaries.add(value);
-                part = builder.setBody(new InputStreamBody(value.getStream(), 
ctype)).build();
+                part = builder.setBody(new InputStreamBody(value.getStream(), 
ctype, paramName)).build();
                 break;
             case PropertyType.NAME:
                 part = builder.setBody(new 
StringBody(resolver.getJCRName(value.getName()), ctype)).build();
{noformat}

producing the request:

{noformat}
....
C-1-#002176 -> [POST /crx/server/crx.default/jcr%3aroot/ HTTP/1.1 ]
C-1-#002227 -> [Referer: 
http://localhost:14502/crx/server/crx.default/jcr%3aroot/ ]
C-1-#002295 -> [Link: <urn:uuid:d8facd27-1a24-4e41-9170-6975f159eb4e>; 
rel="http://www.day.com/jcr/webdav/1.0/session-id"; ]
C-1-#002402 -> [Transfer-Encoding: chunked ]
C-1-#002430 -> [Content-Type: multipart/form-data; 
boundary=UrgdOrJWjR9jfoAvbD1hPbSpABUBUfyDuxq3zT ]
C-1-#002514 -> [Host: localhost:14502 ]
C-1-#002537 -> [Connection: Keep-Alive ]
C-1-#002561 -> [User-Agent: Apache-HttpClient/4.5.3 (Java/1.8.0_131) ]
C-1-#002615 -> [Accept-Encoding: gzip,deflate ]
C-1-#002646 -> [Authorization: Basic YWRtaW46YWRtaW4= ]
C-1-#002685 -> [ ]
C-1-#002687 -> [10f8 ]
C-1-#002693 -> [--UrgdOrJWjR9jfoAvbD1hPbSpABUBUfyDuxq3zT ]
C-1-#002735 -> [Content-Disposition: form-data; 
name="/tmp/test.png/jcr:content/jcr:data"; 
filename="/tmp/test.png/jcr:content/jcr:data" ]
C-1-#002857 -> [Content-Type: jcr-value/binary; charset=UTF-8 ]
C-1-#002904 -> [Content-Transfer-Encoding: binary ]
C-1-#002939 -> [ ]
C-1-#002941 -> [.PNG ]
....
{noformat}


and now it works!


was (Author: tripod):
good catch! I needed to add the filename parameter for the un-chunked test (see 
diff above). that's probably why it worked. 

I tried to add the filename parameter for the chunked case:

{noformat}
diff --git 
a/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2davex/Utils.java 
b/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2davex/Utils.java
index e4ddbf261..7fd552700 100644
--- 
a/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2davex/Utils.java
+++ 
b/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2davex/Utils.java
@@ -98,7 +99,7 @@ final class Utils {
         switch (value.getType()) {
             case PropertyType.BINARY:
                 binaries.add(value);
-                part = builder.setBody(new InputStreamBody(value.getStream(), 
ctype)).build();
+                part = builder.setBody(new InputStreamBody(value.getStream(), 
ctype, paramName)).build();
                 break;
             case PropertyType.NAME:
                 part = builder.setBody(new 
StringBody(resolver.getJCRName(value.getName()), ctype)).build();
{noformat}

and now it works!

> rcp fails to copy binaries correctly
> ------------------------------------
>
>                 Key: JCRVLT-186
>                 URL: https://issues.apache.org/jira/browse/JCRVLT-186
>             Project: Jackrabbit FileVault
>          Issue Type: Bug
>          Components: RCP
>    Affects Versions: 3.1.38
>            Reporter: Tobias Bocanegra
>            Priority: Critical
>         Attachments: 3.1.41_with_chunked.png, 3.1.41_without_chunked.png
>
>
> coping a binary, eg. an image results in data corruption, probably dues to 
> wrong charset setting in the webdav POST:
> {noformat}2017-06-28T15:01:31.114+09:00
> --PuVe35GoHu1NaGvsEEeuI3O1LXf5jbJ
> Content-Disposition: form-data; 
> name="/content/dam/dst/test.png/jcr:content/renditions/cq5dam.web.1280.1280.png/jcr:content/jcr:data"
> Content-Type: jcr-value/binary; charset=UTF-8
> Content-Transfer-Encoding: binary
> ‰PNG
> ....
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to