Skip to content

Commit 3c700cc

Browse files
authored
java.nio.file.Path uses OS dependent file separator character but we (#184)
assume a forward slash to separate "folders" in S3 keys
1 parent 70d8fc6 commit 3c700cc

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

installer/src/main/java/com/amazon/aws/partners/saasfactory/saasboost/SaaSBoostArtifactsBucket.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ public void putFile(S3Client s3, Path localPath, Path remotePath) {
6262
LOGGER.debug("Putting {} to Artifacts bucket: {}", localPath, this);
6363
s3.putObject(PutObjectRequest.builder()
6464
.bucket(bucketName)
65-
.key(remotePath.toString())
65+
// java.nio.file.Path will use OS dependent file separators, so when we run the installer on
66+
// Windows, the S3 key will have back slashes instead of forward slashes. The CloudFormation
67+
// definitions of the Lambda functions will always use forward slashes for the S3Key property.
68+
.key(remotePath.toString().replace('\\', '/'))
6669
.build(), RequestBody.fromFile(localPath)
6770
);
6871
} catch (SdkServiceException s3Error) {

installer/src/test/java/com/amazon/aws/partners/saasfactory/saasboost/SaaSBoostArtifactsBucketTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public void putFileTest() throws Exception {
6060
assertEquals("Put object to the wrong bucket.",
6161
testBucket.getBucketName(), putObjectRequestArgumentCaptor.getValue().bucket());
6262
assertEquals("Put object to the wrong location.",
63-
exampleRemotePath.toString(), putObjectRequestArgumentCaptor.getValue().key());
63+
exampleRemotePath.toString().replace('\\', '/'), putObjectRequestArgumentCaptor.getValue().key());
6464
assertEquals("Put different length object to remote location. Wrong file?",
6565
localPathToTestPut.toFile().length(), requestBodyArgumentCaptor.getValue().contentLength());
6666
}

0 commit comments

Comments
 (0)