Skip to content

Commit

Permalink
SAK-30176 need to base64 encode the id because it may contain UTF8 ch…
Browse files Browse the repository at this point in the history
…ars and S3 does not allow UTF8 chars in metadata sent via REST
  • Loading branch information
ottenhoff committed Jan 4, 2016
1 parent 56003df commit 7f6b5d1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions cloud-content/impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import com.google.common.io.Closeables;
import com.google.inject.Module;

import org.apache.commons.codec.binary.Base64;

import org.jclouds.ContextBuilder;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.blobstore.BlobStore;
Expand Down Expand Up @@ -208,10 +210,11 @@ public long saveInputStream(String id, String root, String filePath, InputStream

Payload payload = Payloads.newInputStreamPayload(in);
BlobStore store = getBlobStore();
String asciiID = Base64.encodeBase64String(id.getBytes("UTF8"));
Blob blob = store.blobBuilder(can.name)
.payload(payload)
.contentLength(size)
.userMetadata(ImmutableMap.of("id", id, "path", filePath))
.userMetadata(ImmutableMap.of("id", asciiID, "path", filePath))
.build();
store.putBlob(can.container, blob);

Expand Down

0 comments on commit 7f6b5d1

Please sign in to comment.