BlobStoreProfile profile = Configurator.getBlobStoreProfile(profileName); String path = BlobUtils.relativize(uri.getPath());
/** * Read Blob contents * * @param uri * @return */ public static InputStream read(URI uri) { // check if blob was stored for the message Assert.notNull(uri, "URI cannot be null"); logger.debug("Reading blob {}", uri); String profileName = uri.getHost(); String container = Configurator.getBlobStoreProfile(profileName).getContainer(); BlobStoreContext context = getBlobStoreContext(profileName); String path = BlobUtils.relativize(uri.getPath()); InputStream in = context.getBlobStore() .getBlob(container, path) .getPayload().getInput(); return in; }
BlobStoreProfile profile = Configurator.getBlobStoreProfile(profileName); ContextBuilder contextBuilder = ContextBuilder.newBuilder(profile.getProvider());
/** * Store Blob * * @param blobName * Blob filename including relative path * @param profileName * Blob store profile name * @param in * Payload * @param size * Payload size in bytes * @return * @throws IOException */ public static void write(final String blobName, final String profileName, InputStream in, final Long size) throws IOException, GeneralSecurityException { Assert.notNull(in, "No data to store"); Assert.notNull(size, "Blob size must be specified"); final String container = Configurator.getBlobStoreProfile(profileName).getContainer(); BlobStoreContext context = getBlobStoreContext(profileName); logger.debug("Storing blob {} on {}", blobName, profileName); BlobStore blobStore = context.getBlobStore(); BlobBuilder blobBuilder = blobStore.blobBuilder(blobName).payload(in).contentLength(size); // store blob blobStore.putBlob(container, blobBuilder.build()); }