Skip to content

Commit

Permalink
Supports the case if the copy source does not start with a leading pa…
Browse files Browse the repository at this point in the history
…th delimiter 🚑

Unlike the Java library, the `aws` CLI does not send a leading path delimiter, leading to an error further down the line.

This was reported by @gerhardj-b.

#230
  • Loading branch information
jakobvogel committed Jun 16, 2023
1 parent add5e7a commit b6e8529
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main/java/ninja/S3Dispatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,8 @@ private void copyObject(WebContext webContext, Bucket bucket, String id, String
String.format("Source '%s' must contain '/'", copy));
return;
}
String srcBucketName = copy.substring(1, copy.indexOf(PATH_DELIMITER, 1));
int cutFrom = copy.startsWith(PATH_DELIMITER) ? PATH_DELIMITER.length() : 0;
String srcBucketName = copy.substring(cutFrom, copy.indexOf(PATH_DELIMITER, cutFrom));
String srcId = copy.substring(copy.indexOf(PATH_DELIMITER, 1) + 1);
Bucket srcBucket = storage.getBucket(srcBucketName);
if (!srcBucket.exists()) {
Expand Down

0 comments on commit b6e8529

Please sign in to comment.