mirror of https://github.com/apache/jclouds.git
JCLOUDS-1005: Percent encode user metadata values
This commit is contained in:
parent
2ff68fc79e
commit
a2e2ff8e4f
|
@ -39,7 +39,7 @@ public final class UploadFileBinder implements MapBinder {
|
|||
.replaceHeader(HttpHeaders.AUTHORIZATION, uploadUrl.authorizationToken())
|
||||
.replaceHeader(B2Headers.FILE_NAME, escaper.escape(fileName));
|
||||
for (Map.Entry<String, String> entry : fileInfo.entrySet()) {
|
||||
builder.replaceHeader(B2Headers.FILE_INFO_PREFIX + entry.getKey(), entry.getValue());
|
||||
builder.replaceHeader(B2Headers.FILE_INFO_PREFIX + entry.getKey(), escaper.escape(entry.getValue()));
|
||||
}
|
||||
return (R) builder.build();
|
||||
}
|
||||
|
|
|
@ -48,7 +48,13 @@ public final class ParseB2ObjectFromResponse implements Function<HttpResponse, B
|
|||
ImmutableMap.Builder<String, String> fileInfo = ImmutableMap.builder();
|
||||
for (Map.Entry<String, String> entry : from.getHeaders().entries()) {
|
||||
if (entry.getKey().regionMatches(true, 0, B2Headers.FILE_INFO_PREFIX, 0, B2Headers.FILE_INFO_PREFIX.length())) {
|
||||
fileInfo.put(entry.getKey().substring(B2Headers.FILE_INFO_PREFIX.length()), entry.getValue());
|
||||
String value;
|
||||
try {
|
||||
value = URLDecoder.decode(entry.getValue(), "UTF-8");
|
||||
} catch (UnsupportedEncodingException uee) {
|
||||
throw Throwables.propagate(uee);
|
||||
}
|
||||
fileInfo.put(entry.getKey().substring(B2Headers.FILE_INFO_PREFIX.length()), value);
|
||||
}
|
||||
}
|
||||
Date uploadTimestamp = new Date(Long.parseLong(from.getFirstHeaderOrNull(B2Headers.UPLOAD_TIMESTAMP)));
|
||||
|
|
Loading…
Reference in New Issue