Search in sources :

Example 1 with FileStorage

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;
}
Also used : StrictYamlMapping(com.amihaiemil.eoyaml.StrictYamlMapping) EtcdStorage(com.artipie.asto.etcd.EtcdStorage) Storage(com.artipie.asto.Storage) FileStorage(com.artipie.asto.fs.FileStorage) S3Storage(com.artipie.asto.s3.S3Storage) FileStorage(com.artipie.asto.fs.FileStorage) YamlMapping(com.amihaiemil.eoyaml.YamlMapping) StrictYamlMapping(com.amihaiemil.eoyaml.StrictYamlMapping) EtcdStorage(com.artipie.asto.etcd.EtcdStorage) S3Storage(com.artipie.asto.s3.S3Storage)

Example 2 with FileStorage

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));
}
Also used : PublisherAs(com.artipie.asto.ext.PublisherAs) FileStorage(com.artipie.asto.fs.FileStorage) Key(com.artipie.asto.Key) Test(org.junit.jupiter.api.Test)

Example 3 with FileStorage

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))));
}
Also used : BlockingStorage(com.artipie.asto.blocking.BlockingStorage) Storage(com.artipie.asto.Storage) FileStorage(com.artipie.asto.fs.FileStorage) InMemoryStorage(com.artipie.asto.memory.InMemoryStorage) BlockingStorage(com.artipie.asto.blocking.BlockingStorage) FileStorage(com.artipie.asto.fs.FileStorage) TestResource(com.artipie.asto.test.TestResource) Key(com.artipie.asto.Key)

Example 4 with FileStorage

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;
}
Also used : StrictYamlMapping(com.amihaiemil.eoyaml.StrictYamlMapping) EtcdStorage(com.artipie.asto.etcd.EtcdStorage) Storage(com.artipie.asto.Storage) FileStorage(com.artipie.asto.fs.FileStorage) S3Storage(com.artipie.asto.s3.S3Storage) FileStorage(com.artipie.asto.fs.FileStorage) YamlMapping(com.amihaiemil.eoyaml.YamlMapping) StrictYamlMapping(com.amihaiemil.eoyaml.StrictYamlMapping) EtcdStorage(com.artipie.asto.etcd.EtcdStorage) S3Storage(com.artipie.asto.s3.S3Storage)

Aggregations

FileStorage (com.artipie.asto.fs.FileStorage)4 Storage (com.artipie.asto.Storage)3 StrictYamlMapping (com.amihaiemil.eoyaml.StrictYamlMapping)2 YamlMapping (com.amihaiemil.eoyaml.YamlMapping)2 Key (com.artipie.asto.Key)2 EtcdStorage (com.artipie.asto.etcd.EtcdStorage)2 S3Storage (com.artipie.asto.s3.S3Storage)2 BlockingStorage (com.artipie.asto.blocking.BlockingStorage)1 PublisherAs (com.artipie.asto.ext.PublisherAs)1 InMemoryStorage (com.artipie.asto.memory.InMemoryStorage)1 TestResource (com.artipie.asto.test.TestResource)1 Test (org.junit.jupiter.api.Test)1