Skip to content
Permalink
Browse files
Encode filename in B2 download URL
Previously this caused downloads of file names with % to fail.
  • Loading branch information
gaul committed Apr 8, 2017
1 parent 1b0615c commit c429ad81761919bb6a82ccad400d0c93381d4633
Showing 1 changed file with 8 additions and 1 deletion.
@@ -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 @@ private MutableBlobMetadata toBlobMetadata(String container, B2Object b2Object)
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;
}
}

0 comments on commit c429ad8

Please sign in to comment.