Encode filename in B2 download URL

Previously this caused downloads of file names with % to fail.
This commit is contained in:
Andrew Gaul 2017-04-08 15:43:45 -07:00
parent 0d3b88be97
commit c94dfa23e1
1 changed files with 8 additions and 1 deletions

View File

@ -16,7 +16,9 @@
*/
package org.jclouds.b2.blobstore;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URLEncoder;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -480,7 +482,12 @@ public final class B2BlobStore extends BaseBlobStore {
contentMetadata.setContentType(b2Object.contentType());
metadata.setContentMetadata(contentMetadata);
metadata.setUserMetadata(b2Object.fileInfo());
metadata.setPublicUri(URI.create(auth.get().downloadUrl() + "/file/" + container + "/" + b2Object.fileName()));
try {
metadata.setPublicUri(URI.create(auth.get().downloadUrl() + "/file/" + container + "/" +
URLEncoder.encode(b2Object.fileName(), "UTF-8")));
} catch (UnsupportedEncodingException uee) {
throw new RuntimeException(uee);
}
return metadata;
}
}