use of com.artipie.asto.fs.FileStorage in project front by artipie.
the class YamlStorage method storage.
/**
* Provides a storage.
*
* @return Storage instance.
*/
public Storage storage() {
@SuppressWarnings("deprecation") final YamlMapping strict = new StrictYamlMapping(this.yaml);
final String type = strict.string("type");
final Storage storage;
if ("fs".equals(type)) {
storage = new FileStorage(Path.of(strict.string("path")));
} else if ("s3".equals(type)) {
storage = new S3Storage(this.s3Client(), strict.string("bucket"), !"false".equals(this.yaml.string("multipart")));
} else if ("etcd".equals(type)) {
storage = new EtcdStorage(YamlStorage.etcdClient(strict.yamlMapping("connection")));
} else {
throw new IllegalStateException(String.format("Unsupported storage type: '%s'", type));
}
return storage;
}
use of com.artipie.asto.fs.FileStorage in project artipie by artipie.
the class StorageYamlConfigTest method returnsSubStorageWithCorrectPrefix.
@Test
void returnsSubStorageWithCorrectPrefix() throws IOException {
final Key prefix = new Key.From("prefix");
final Key path = new Key.From("some/path");
final Key full = new Key.From(prefix, path);
final byte[] data = "content".getBytes();
this.config().subStorage(prefix).save(path, new Content.From(data)).join();
MatcherAssert.assertThat(new PublisherAs(new FileStorage(this.tmp).value(full).join()).bytes().toCompletableFuture().join(), new IsEqual<>(data));
}
use of com.artipie.asto.fs.FileStorage in project maven-adapter by artipie.
the class AstoMavenTest method addFilesToStorage.
private void addFilesToStorage(final Predicate<String> condition, final Key base) {
final Storage resources = new FileStorage(new TestResource("com/artipie/asto").asPath());
final BlockingStorage bsto = new BlockingStorage(resources);
bsto.list(Key.ROOT).stream().map(Key::string).filter(condition).forEach(item -> new BlockingStorage(this.storage).save(new Key.From(base, item), bsto.value(new Key.From(item))));
}
use of com.artipie.asto.fs.FileStorage in project artipie by artipie.
the class YamlStorage method storage.
/**
* Provides a storage.
*
* @return Storage instance.
*/
public Storage storage() {
@SuppressWarnings("deprecation") final YamlMapping strict = new StrictYamlMapping(this.yaml);
final String type = strict.string("type");
final Storage storage;
if ("fs".equals(type)) {
storage = new FileStorage(Path.of(strict.string("path")));
} else if ("s3".equals(type)) {
storage = new S3Storage(this.s3Client(), strict.string("bucket"), !"false".equals(this.yaml.string("multipart")));
} else if ("etcd".equals(type)) {
storage = new EtcdStorage(YamlStorage.etcdClient(strict.yamlMapping("connection")));
} else {
throw new IllegalStateException(String.format("Unsupported storage type: '%s'", type));
}
return storage;
}
Aggregations