Skip to content

Support list operation for s3 storage #424

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions dev/cosbench-s3/src/com/intel/cosbench/api/S3Stor/S3Storage.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static com.intel.cosbench.client.S3Stor.S3Constants.*;

import java.io.*;
import java.util.List;

import org.apache.http.HttpStatus;

Expand Down Expand Up @@ -101,6 +102,26 @@ public InputStream getObject(String container, String object, Config config) {
}
return stream;
}

@Override
public InputStream getList(String container, String prefix, Config config) {
super.getList(container, prefix, config);
InputStream stream;
try {
ObjectListing s3ObjList = client.listObjects(container, prefix);
List<S3ObjectSummary> objSummaries = s3ObjList.getObjectSummaries();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
for (S3ObjectSummary s : objSummaries) {
baos.write(s.toString().getBytes());
}
byte[] bytes = baos.toByteArray();
stream = new ByteArrayInputStream(bytes);

} catch (Exception e) {
throw new StorageException(e);
}
return stream;
}

@Override
public void createContainer(String container, Config config) {
Expand Down