How to generate native blobstore blob path from a blob ID

Given you only have a native blobstore blob ID value, you can programatically determine where this blob will end up in the native blobstore of Nexus Repository Manager 3.

The logic to generate the path, excluding the file extension, inside a native blobstore is isolated to one class file:

 * Sonatype Nexus (TM) Open Source Version
 * Copyright (c) 2008-present Sonatype, Inc.
 * All rights reserved. Includes the third-party code listed at
 * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0,
 * which accompanies this distribution and is available at
 * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks
 * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
 * Eclipse Foundation. All other trademarks are the property of their respective owners.


import static;

 * Stores blobs in a two-deep directory tree.
 * The first layer, {@code vol}, having {@link #TIER_1_MODULO} directories,
 * and the second {@code chap} having {@link #TIER_2_MODULO}.
 * @since 3.0
public class VolumeChapterLocationStrategy
    extends LocationStrategySupport
  private static final int TIER_1_MODULO = 43;

  private static final int TIER_2_MODULO = 47;

  public String location(final BlobId blobId) {

    return String.format("vol-%02d/chap-%02d/%s",
        tier(blobId, TIER_1_MODULO),
        tier(blobId, TIER_2_MODULO),

  private int tier(final BlobId blobId, final int modulo) {
    return Math.abs(blobId.hashCode() % modulo) + 1;
Have more questions? Submit a request


Article is closed for comments.