|
20 | 20 | import ch.cyberduck.core.features.AttributesFinder; |
21 | 21 | import ch.cyberduck.core.features.Bulk; |
22 | 22 | import ch.cyberduck.core.features.Delete; |
| 23 | +import ch.cyberduck.core.features.Read; |
23 | 24 | import ch.cyberduck.core.features.Write; |
24 | 25 | import ch.cyberduck.core.io.StatusOutputStream; |
25 | 26 | import ch.cyberduck.core.proxy.ProxyFactory; |
|
49 | 50 | import java.io.ByteArrayInputStream; |
50 | 51 | import java.io.File; |
51 | 52 | import java.io.IOException; |
| 53 | +import java.io.InputStream; |
52 | 54 | import java.util.AbstractMap; |
53 | 55 | import java.util.Arrays; |
54 | 56 | import java.util.Collections; |
@@ -99,11 +101,11 @@ public void listMinio() throws BackgroundException, IOException { |
99 | 101 | new S3BucketCreateService(storage).create(bucket, "us-east-1"); |
100 | 102 |
|
101 | 103 | final List<String> files = Arrays.asList( |
102 | | - "/d/RZ/K7ZH7KBXULNEKBMGX3CU42PGUIAIX4/rExOms183v5evFwgIKiW0qvbsor1Hg==.uvf/dir.uvf", |
103 | | - "/d/RZ/K7ZH7KBXULNEKBMGX3CU42PGUIAIX4/dir.uvf", |
104 | | - "/d/RZ/K7ZH7KBXULNEKBMGX3CU42PGUIAIX4/GsMMTRvsuuP_6NjgRwopmWcuof-PyRQ=.uvf", |
105 | | - "/d/TU/EVUUXMHY2HHNQ4BLKNE3GBLEFD4YW6/4RuVMuXcOTOfhSQZAwEV1E4XiNrMVOY=.uvf", |
106 | | - "/d/TU/EVUUXMHY2HHNQ4BLKNE3GBLEFD4YW6/dir.uvf" |
| 104 | + "/d/RZ/K7ZH7KBXULNEKBMGX3CU42PGUIAIX4/rExOms183v5evFwgIKiW0qvbsor1Hg==.uvf/dir.uvf", // -> /subir |
| 105 | + "/d/RZ/K7ZH7KBXULNEKBMGX3CU42PGUIAIX4/dir.uvf", // -> / |
| 106 | + "/d/RZ/K7ZH7KBXULNEKBMGX3CU42PGUIAIX4/GsMMTRvsuuP_6NjgRwopmWcuof-PyRQ=.uvf", // -> /foo.txt |
| 107 | + "/d/6L/HPWBEU3OJP2EZUCP4CV3HHL47BXVEX/5qTOPMA1BouBRhz_G7qfmKety92geI4=.uvf", // -> /subdir/bar.txt |
| 108 | + "/d/6L/HPWBEU3OJP2EZUCP4CV3HHL47BXVEX/dir.uvf" // /subdir |
107 | 109 | ); |
108 | 110 | final String jwe = "{\n" + |
109 | 111 | " \"fileFormat\": \"AES-256-GCM-32k\",\n" + |
@@ -152,14 +154,32 @@ public Credentials prompt(final Host bookmark, final String title, final String |
152 | 154 | { |
153 | 155 | final AttributedList<Path> list = storage.getFeature(ListService.class).list(home, new DisabledListProgressListener()); |
154 | 156 | assertEquals(2, list.size()); |
155 | | - assertTrue(Arrays.toString(list.toArray()), list.contains(new Path("/cyberduckbucket/foo.txt", EnumSet.of(AbstractPath.Type.file, AbstractPath.Type.decrypted)))); |
| 157 | + final Path foo = new Path("/cyberduckbucket/foo.txt", EnumSet.of(AbstractPath.Type.file, AbstractPath.Type.decrypted)); |
| 158 | + assertTrue(Arrays.toString(list.toArray()), list.contains(foo)); |
156 | 159 | assertTrue(Arrays.toString(list.toArray()), list.contains(new Path("/cyberduckbucket/subdir", EnumSet.of(AbstractPath.Type.directory, AbstractPath.Type.placeholder, AbstractPath.Type.decrypted)))); |
| 160 | + |
| 161 | + final byte[] buf = new byte[300]; |
| 162 | + final TransferStatus status = new TransferStatus(); |
| 163 | + try(final InputStream inputStream = storage.getFeature(Read.class).read(foo, status, new DisabledConnectionCallback())) { |
| 164 | + int l = inputStream.read(buf); |
| 165 | + assertEquals(9, l); |
| 166 | + assertEquals("Hello Foo", new String(Arrays.copyOfRange(buf, 0, l))); |
| 167 | + } |
157 | 168 | } |
158 | 169 | { |
159 | 170 | final PathAttributes subdir = storage.getFeature(AttributesFinder.class).find(new Path("/cyberduckbucket/subdir", EnumSet.of(AbstractPath.Type.directory, AbstractPath.Type.placeholder, AbstractPath.Type.decrypted))); |
160 | 171 | final AttributedList<Path> list = storage.getFeature(ListService.class).list(new Path("/cyberduckbucket/subdir", EnumSet.of(AbstractPath.Type.directory, AbstractPath.Type.placeholder, AbstractPath.Type.decrypted)).withAttributes(subdir), new DisabledListProgressListener()); |
161 | 172 | assertEquals(1, list.size()); |
162 | | - assertTrue(Arrays.toString(list.toArray()), list.contains(new Path("/cyberduckbucket/subdir/bar.txt", EnumSet.of(AbstractPath.Type.file, AbstractPath.Type.decrypted)))); |
| 173 | + final Path bar = new Path("/cyberduckbucket/subdir/bar.txt", EnumSet.of(AbstractPath.Type.file, AbstractPath.Type.decrypted)); |
| 174 | + assertTrue(Arrays.toString(list.toArray()), list.contains(bar)); |
| 175 | + |
| 176 | + final byte[] buf = new byte[300]; |
| 177 | + final TransferStatus status = new TransferStatus(); |
| 178 | + try(final InputStream inputStream = storage.getFeature(Read.class).read(bar, status, new DisabledConnectionCallback())) { |
| 179 | + int l = inputStream.read(buf); |
| 180 | + assertEquals(9, l); |
| 181 | + assertEquals("Hello Bar", new String(Arrays.copyOfRange(buf, 0, l))); |
| 182 | + } |
163 | 183 | } |
164 | 184 | } |
165 | 185 | finally { |
|
0 commit comments