Skip to content

Commit

Permalink
Remove directory level in ObjectNamePrefix Naming Strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
sydney-munro committed Jan 18, 2024
1 parent c7d14b0 commit b2fe993
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ public static PartNamingStrategy prefix(String prefixPattern) {
* <p>General format is
*
* <pre><code>
* {objectName}-parts/{randomKeyDigest};{objectInfoDigest};{partIndex}.part
* {objectName}-{randomKeyDigest};{objectInfoDigest};{partIndex}.part
* </code></pre>
*
* <p>{@code {objectInfoDigest}} will be fixed for an individual {@link BlobWriteSession}.
Expand All @@ -539,11 +539,11 @@ public static PartNamingStrategy prefix(String prefixPattern) {
* @since 2.30.2 This new api is in preview and is subject to breaking changes.
*/
@BetaApi
public static PartNamingStrategy objectNamePrefix() {
return objectNamePrefix("");
public static PartNamingStrategy useObjectNameAsPrefix() {
return useObjectNameAsPrefix("");
}

private static PartNamingStrategy objectNamePrefix(String prefixPattern) {
private static PartNamingStrategy useObjectNameAsPrefix(String prefixPattern) {
checkNotNull(prefixPattern, "prefixPattern must be non null");
SecureRandom rand = new SecureRandom();
return new WithObjectLevelPrefix(rand, prefixPattern);
Expand Down Expand Up @@ -594,8 +594,7 @@ protected String fmtFields(String randomKey, String ultimateObjectName, String p
String nameDigest = B64.encodeToString(hashCode.asBytes());
return prefix
+ ultimateObjectName
+ "-parts"
+ "/"
+ "-"
+ randomKey
+ FIELD_SEPARATOR
+ nameDigest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void partNameStrategy_prefix_stillWorksWithFmtPattern() throws Exception
public void partNameStrategy_objectNamePrefix() throws Exception {
// Creating an object level prefix without specifying an additional prefix will append the
// object name to the beginning of the part name.
PartNamingStrategy strategy = PartNamingStrategy.objectNamePrefix();
PartNamingStrategy strategy = PartNamingStrategy.useObjectNameAsPrefix();

String fmt = strategy.fmtName("a/b/obj", PartRange.of(1, 96));
assertAll(
Expand Down

0 comments on commit b2fe993

Please sign in to comment.